-3
A
回答
0
0
加入这个依赖于你的gradle这个文件..
com.github.rampo.updatechecker:library:2.1.8
并尝试在你的Activity这个代码..
public static String NEW_VERSION = "1.1.0";
public void checkForAppUpdate() {
try {
if (!((Activity) context).isFinishing()) {
UpdateChecker.setNotice(Notice.NOTIFICATION);
UpdateChecker.setNoticeIcon(R.drawable.your_notification_logo);
String s = "Hello User, New version of this application is now available on play store.";
if (Comparator.isVersionDownloadableNewer((Activity) context, NEW_VERSION)){
SharedPreferences pref = context.getSharedPreferences(UpdateChecker.PREFS_FILENAME, 0);
boolean b = pref.getBoolean(UpdateChecker.DONT_SHOW_AGAIN_PREF_KEY + NEW_VERSION, false);
if (!b) {
displayAlertDialogforPlayStore(context, "Update Available", s);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
与功能displayAlertDialogforPlayStore()是...
public void displayAlertDialogforPlayStore(final Context context, String title,
String message) {
try {
final AlertDialog.Builder alert = new AlertDialog.Builder(context);
alert.setIcon(R.drawable.your_notification_logo);
if (title != null) {
alert.setTitle(title);
}
alert.setMessage(message);
alert.setPositiveButton("Update Now", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final String appPackageName = context.getPackageName();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=" + appPackageName));
context.startActivity(intent);
}
});
alert.setNegativeButton("Later", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
alert.show();
} catch (Exception e) {
e.printStackTrace();
}
}
此代码显示通知和alertDailog以进行更新。
相关问题
- 1. 在应用程序中通知用户有新版本
- 2. Android:通知较新版本的用户
- 3. Facebook应用程序用户的通知
- 4. Android应用更新通知
- 5. Android:如何在应用程序未运行时通知用户
- 6. 当用户卸载Android应用程序时发出通知
- 7. 如果用户没有点击通知,swift通知更新应用程序
- 8. 如何通知用户更新他们的应用程序
- 9. 通知用户一个新的应用程序
- 10. RSS通知Android应用程序
- 11. Android通知,如Skype应用程序
- 12. Android:应用程序启动通知
- 13. Android应用程序的推送通知
- 14. 新版本的Android应用程序
- 15. 当用户点击Urban Airship通知时重新启动android应用程序
- 16. 应用程序更新推送通知
- 17. Facebook Android客户端自定义应用程序通知
- 18. 通知Android:当应用程序打开时不显示通知?
- 19. Android通知重新启动应用程序,但想要恢复
- 20. Pub/Sub如何通知用户登录订户应用程序?
- 21. Facebook Unity SDK - 应用程序到用户通知不起作用
- 22. 当用户不使用应用程序时24小时通知
- 23. 通知用户关于应用程序商店中应用程序的新更新作为警报并自动在iPhone中安装更新的版本?
- 24. Android:发送通知到PHP服务器通知栏到android应用程序
- 25. 将应用程序发送给用户通知栏上的通知
- 26. 如何发送通知给Android应用程序中的相同应用程序的注册用户
- 27. Android:用户打开短信应用程序或手机应用程序/未接电话列表时的通知
- 28. 发送android应用程序通知到Facebook使用Facebook API通知
- 29. Android试用版应用程序
- 30. 当通过网站插入新记录时通知android应用程序中的用户
我认为你的问题是重复的。我为一个非常相似的问题写了一个答案。你能否检查一下,看看我们是否知道? http://stackoverflow.com/a/40029702/3732187 –