I'm developing an app that ask the user for rating it in the Play Store. It works well. If the user presses the Rate button it leads to the Play Store page for the app. Than if you press the Back button, my app goes in front showing the rating dialog. I used dialog.dismiss()
just before or after starting the Play Store intent, but the dialog wont dismiss, it stays there.
Here's my code, please help me!
private void rateDialog() {
AlertDialog.Builder mDialogBuilder;
mDialogBuilder = new AlertDialog.Builder(MainActivity.this);
mDialogBuilder.setCancelable(true);
mDialogBuilder.setTitle(getString(R.string.title_RateDialog));
if (!appdata.getBoolean(Constants.IS_RATE_IGNORED, false) && (appdata.getInt(Constants.START_COUNT, 1) % 4) == 0) {
mDialogBuilder.setMessage(getString(R.string.text_RateDialogMessage));
mDialogBuilder.setPositiveButton(R.string.text_OK,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
appdataEditor.putBoolean(Constants.IS_RATE_IGNORED, true);
dialog.dismiss();
try{
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.PLAY_STORE_URL)));
} catch (ActivityNotFoundException e){
Toast.makeText(getApplicationContext(), "Could not open market page.", Toast.LENGTH_LONG).show();
}
}
});
mDialogBuilder.setNeutralButton(getString(R.string.text_NotNow),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
mDialogBuilder.setNegativeButton(getString(R.string.text_Never),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int id) {
appdataEditor.putBoolean(Constants.IS_RATE_IGNORED, true);
}
});
AlertDialog rateDialog = mDialogBuilder.create();
rateDialog.show();
}
}
I call this in the onStart()
method.