In my app, I show the push notification as a Dialog that has two buttons named 'Yes' and 'No'. I need to show a timer(20secs) running on Dialog Title. If we click 'Yes', It should go to an activity, If 'No' dialog gets canceled before timer ends, After finishing the counting,the Dialog should disappear. Any Idea?? Here is my Alert dialog Method
public void showAlertDialog(final Context context, String title, String message,
Boolean status)
{
AlertDialog.Builder alertDialog = new AlertDialog.Builder(context);
// Setting Dialog Title
alertDialog.setTitle(title);
// Setting Dialog Message
alertDialog.setMessage(message);
// Setting Icon to Dialog
//alertDialog.setIcon(R.drawable.fail);
// Setting Positive "Yes" Button
alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int which) {
Toast.makeText(getApplicationContext(), "You clicked on YES", Toast.LENGTH_SHORT).show();
}
});
// Setting Negative "NO" Button
alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "You clicked on NO", Toast.LENGTH_SHORT).show();
dialog.cancel();
}
});
// Showing Alert Message
//alertDialog.setIcon(R.drawable.counter);
alertDialog.show();
}
}
0 comments:
Post a Comment