首先你需要有一个 api 如何跟踪用户版本是否过时..
例如,您将应用当前版本发送到这样的 API:
String version = String.valueOf(BuildConfig.VERSION_CODE);
如果 response.body().isUpdateRequired() 为真,那么您需要在下面调用此警报:
AlertDialog.Builder alertDialog = new AlertDialog.Builder(SplashActivity.this);
alertDialog.setTitle("Please update your app");
alertDialog.setMessage("This app version is not supported any longer. Please update your app from the Play Store.");
alertDialog.setPositiveButton("UPDATE NOW", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
final String appPackageName = getPackageName();
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}
}
});
alertDialog.show();