我不知道這個問題是否被問到,但我找不到它。 我希望提醒對話框每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的地方,並和增量,並檢查它每次啓動 –