@Override
public void onBackPressed() {
// TODO Auto-generated method stub
AlertDialog.Builder builder=new AlertDialog.Builder(mContext);
// builder.setCancelable(false);
builder.setTitle("Rate Us if u like this");
builder.setMessage("Do you want to Exit?");
builder.setPositiveButton("yes",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Toast.makeText(mContext, "Yes i wanna exit", Toast.LENGTH_LONG).show();
finish();
}
});
builder.setNegativeButton("No",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Toast.makeText(mContext, "i wanna stay on this page", Toast.LENGTH_LONG).show();
dialog.cancel();
}
});
builder.setNeutralButton("Rate",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
final String appPackageName = getPackageName(); // getPackageName() from Context or Activity object
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName())));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + getPackageName())));
}
}
});
AlertDialog alert=builder.create();
alert.show();
//super.onBackPressed();
}
我明白了。我自己解決了。 – Jyosna
那麼你應該把你的代碼放在這裏。 –