简体   繁体   English

Android:如何仅显示一次应用内更新

[英]Android: How to display in-app update only once

Is it possible to display the flexible in-app update only once using just the Google API?是否可以仅使用 Google API 仅显示一次灵活的应用内更新? Eg.:例如。:

  1. User opens the app.用户打开应用程序。
  2. There is a new version.有一个新版本。
  3. Display flexible in-app update dialog.显示灵活的应用内更新对话框。
  4. User cancels the dialog.用户取消对话。
  5. User opens the app again but the dialog is not shown.用户再次打开应用程序,但未显示对话框。

Is it possible to achieve that with Google Core API or do I need to somehow store that information (that dialog was displayed but canceled) on my own?是否可以使用 Google Core API 来实现这一点,还是我需要以某种方式自行存储该信息(该对话框已显示但已取消)?

Use a flag using shared preferences like below.使用使用共享首选项的标志,如下所示。 Then check if the value has been edited before..if not app update然后检查该值是否已被编辑过..如果不是应用程序更新

SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putBoolean("isAppUpdateShown", false);
editor.commit(); 

if(sharedPref.getBoolean("locked", false)){
//app update code
editor.putBoolean("isAppUpdateShown", true);

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM