android - AlertDialog is not showing in other activity -
android - AlertDialog is not showing in other activity -
function:
alert dialog method created notify user on status of account, hence, dialog pop-up when user has been logged out remotely. furthermore, there 4 activities within app; hence, when business relationship logged, dialog pop-up when user decides navigate next activity. dialog pop-up navigate user login page when has been acknowledged.
issue:
alert dialog doesn't pop when user business relationship has been logged out, logout bttn has been changed login , sharedpreference credentials have been cleared. still allows user navigate around app, app displayed after delayed period.
what has gone wrong codes , suggestions?
code
//build alertdialog notify user on session logout status static builder alertdialog(final activity act,final intent yourintent){ log.i("rootactivity:alertdialog","******session logout info******"); alertdialog.builder alertdialog = new alertdialog.builder(act); alertdialog.settitle("sign in spacetobe services"); alertdialog.setmessage("for security reasons, have been automatically logged out after 20 minutes of inactivity." + "to access spacetobe services, please sign in again."); alertdialog.setcancelable(false); //setting of ok button alertdialog.setpositivebutton("ok", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { //intent yourintent = new intent(intent.action_view); //yourintent.setflags(intent.flag_activity_brought_to_front); act.startactivity(yourintent);//return page propertyactivity } }); homecoming alertdialog; } //logout method & clearing of shared preference credentials public void idlelogout(){ log.i("rootactivity:idlelogout()","******app loggedout******"); //sharedpreference method cleared log.i("rootactivity:idlelogout()","******loginbutton set******"); setloginbutton(); // alter logout button login checktimeout=true; // global timeout true //rootactivity.alertdialog(this,getcustomintent(propertyactivity.class)).create().show(); } //edited version logout dialog when user tries navigate other activity bttn when logged out @override public void onbackpressed(){ log.i("rootactivity:onbackpreseed()","******back bttn has been selected******"); if (checktimeout==true){ log.i("rootactivity:oncreate(bundle savedinstancestate)","******timeout=true******"); rootactivity.alertdialog(this,getcustomintent(propertyactivity.class)).create().show(); checktimeout = false; }return; } //end of edited version logout dialog when user tries navigate other activity bttn when logged out // each new individual activity @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); context = this; //edited version start time each user interaction activity starttime=system.currenttimemillis(); log.i("rootactivity:oncreate(bundle savedinstancestate)","******starttime=******"+starttime); //end of edited version start time each user interaction activity //edited version logout dialog when user tries navigate other activity when logged out if (checktimeout==true){ log.i("rootactivity:oncreate(bundle savedinstancestate)","******timeout=true******"); rootactivity.alertdialog(this,getcustomintent(propertyactivity.class)).create().show(); checktimeout = false; }return; //end of edited version logout dialog when user tries navigate other activity when logged out }
move dialog code onresume() method, @ time, activity visible.
android alertdialog android-alertdialog
Comments
Post a Comment