android - Alertbox closing Automatically before Intent -
i want show alertbox before intent in activity.after click "ok" button intent should work in case alertbox showing intent working.i mean alertbox closing automatically before intent. activity code
alert.showalertdialogpostive(changepass.this, "successfully submited", "password changed successfully", true); userfunctions userfunction = new userfunctions(); userfunction.logoutuser(getapplicationcontext()); intent dashboard = new intent(getapplicationcontext(), loginactivity.class); // close views before launching dashboard dashboard.addflags(intent.flag_activity_clear_top); startactivity(dashboard); // close registration screen finish();
and alert builder class
@suppresswarnings("deprecation") public void showalertdialogpostive(context context, string title, string message, boolean status) { final alertdialog alertdialog = new alertdialog.builder(context).create(); // setting dialog title alertdialog.settitle(title); alertdialog.setcancelable(false); // setting dialog message alertdialog.setmessage(message); if(status != null) // setting alert dialog icon alertdialog.seticon((status) ? r.drawable.success : r.drawable.success); // setting ok button alertdialog.setbutton("ok", new dialoginterface.onclicklistener() { public void onclick(final dialoginterface dialog, final int which) { alertdialog.dismiss(); } }); // showing alert message alertdialog.show(); }
intent should work after clicking ok button in alert box.help me !
userfunctions userfunction = new userfunctions(); userfunction.logoutuser(getapplicationcontext()); intent dashboard = new intent(getapplicationcontext(), loginactivity.class); // close views before launching dashboard dashboard.addflags(intent.flag_activity_clear_top); startactivity(dashboard); // close registration screen finish();
move above code inside alert's button click. code below,
@suppresswarnings("deprecation") public void showalertdialogpostive(context context, string title, string message, boolean status) { final alertdialog alertdialog = new alertdialog.builder(context).create(); // setting dialog title alertdialog.settitle(title); alertdialog.setcancelable(false); // setting dialog message alertdialog.setmessage(message); if(status != null) // setting alert dialog icon alertdialog.seticon((status) ? r.drawable.success : r.drawable.success); // setting ok button alertdialog.setbutton("ok", new dialoginterface.onclicklistener() { public void onclick(final dialoginterface dialog, final int which) { userfunctions userfunction = new userfunctions(); userfunction.logoutuser(getapplicationcontext()); intent dashboard = new intent(getapplicationcontext(), loginactivity.class); // close views before launching dashboard dashboard.addflags(intent.flag_activity_clear_top); startactivity(dashboard); // close registration screen finish(); } }); // showing alert message alertdialog.show(); }
Comments
Post a Comment