我不知道这个问题是否被问到,但我找不到它。 我希望提醒对话框每10次或更多次显示应用程序启动。如何每10次启动显示警报对话框?
AlertDialog.Builder a_builder = new AlertDialog.Builder(MainActivity.this);
a_builder.setMessage("Please take time and rate our application")
.setCancelable(false)
.setPositiveButton("Yes",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Uri uri = Uri.parse("market://details?id=" + getApplicationContext().getPackageName());
Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY |
Intent.FLAG_ACTIVITY_NEW_DOCUMENT |
Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
try {
startActivity(goToMarket);
} catch (ActivityNotFoundException e) {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://play.google.com/store/apps/details?id=" + getApplicationContext().getPackageName())));
}
}
}).setNegativeButton("Not Now",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
}) ;
AlertDialog alert = a_builder.create();
alert.setTitle("Rate Us !");
alert.show();
可以使用sharedPreferences来存储您的柜台,检查每一个应用程序推出的价值 – Roljhon
商店的推出数量INT的地方,并和增量,并检查它每次启动 –