android - Resume Alert Dialog state on Back button pressed -
i have deal alert dialog in android app. in first activity there 1 alert dialog.on particular action, alert dialog appears. when user clicks yes button of alert dialog, user moves second activity. in second activity, have 1 button. on pressing of button alert dialog should prompted again same state. possible resume state of alert dialog on button pressed? code dialog...
// alert dialog input @override protected dialog oncreatedialog(int id) { alertdialog dialogdetails = null; switch (id) { case dialog_login: layoutinflater inflater = layoutinflater.from(this); view dialogview = inflater.inflate(r.layout.dialog, null); alertdialog.builder dialogbuilder = new alertdialog.builder(this); dialogbuilder.setview(dialogview); dialogdetails = dialogbuilder.create(); break; case list_dialog : layoutinflater inflater2 = layoutinflater.from(this); view dialogview1 = inflater2.inflate(r.layout.listdialog, null); alertdialog.builder dialogbuilder2 = new alertdialog.builder(this); dialogbuilder2.setview(dialogview1); dialogdetails = dialogbuilder2.create(); } return dialogdetails; } @override protected void onpreparedialog(int id, dialog dialog) { switch (id) { case dialog_login: final alertdialog alertdialog = (alertdialog) dialog; button btnsave = (button) alertdialog.findviewbyid(r.id.btnsave); button btncancel = (button) alertdialog.findviewbyid(r.id.btncancel); etlist = (edittext) alertdialog.findviewbyid(r.id.etlist); btnsave.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { newlist = etlist.length(); // todo auto-generated method stub if ( newlist <= 0) { etlist.requestfocus(); toast.maketext(getbasecontext(), "enter name of list", 1000).show(); } else { listdata = etlist.gettext().tostring().replaceall(system.getproperty("line.separator"), ""); if(listdata.length() > 0) { datapass(listdata); createfile(listdata); } else { toast.maketext(getbasecontext(), "enter name of list", 1000).show(); } } } }); btncancel.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub dismissdialog(dialog_login); etlist.settext(""); } }); break; case list_dialog: alertdialog alertdialog1 = (alertdialog) dialog; lvdialog = (listview) alertdialog1.findviewbyid(r.id.list1); textview tvadd = (textview) alertdialog1.findviewbyid(r.id.txtadd); tvdone = (textview) alertdialog1.findviewbyid(r.id.txtdone); if(listname.length() <= 7) { tvadd.settext("add friends to" +" " + listname ); } else { tvadd.settext("add friends to" +" " + listname.substring(0, 5) + ".."); } tvdone.setonclicklistener(new onclicklistener() { @suppresswarnings("deprecation") @override public void onclick(view v) { // todo auto-generated method stub if( colorrow > 0 ) { alertdialog builder = new alertdialog.builder(newfriendlist.this).create(); builder.settitle("save list"); builder.setmessage("do want save?"); builder.setbutton("save", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { removables = new arraylist<string>(); for(int c= 0; c<checked.size(); c++) { int key = checked.keyat(c); if(checked.get(key, false)) { removables.add(arr2.get(key)); memap.put(listname, arr2.get(key)); } } try { writetofile(removables , listname); dismissdialog(list_dialog); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } } }); builder.setbutton2("cancel", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { chktext.settextcolor(color.black); colorrow = 0; } }); builder.show(); } else toast.maketext(getbasecontext(), "select friends", 1000).show(); } }); lvdialog.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> arg0, view arg1, int arg2, long arg3) { // todo auto-generated method stub checked = lvdialog.getcheckeditempositions(); chktext = (checkedtextview) arg1.findviewbyid(r.id.txt); if(checked.get(arg2)) { chktext.settextcolor(color.cyan); colorrow ++; } else { chktext.settextcolor(color.black); //colorrow--; colorrow = 0; } } }); // cancel alert dialog imageview ivcancel = (imageview) alertdialog1.findviewbyid(r.id.imgcancel); ivcancel.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub dismissdialog(list_dialog); arr2.clear(); } }); // friend list showfriendlist(); break; }
logcat
??-?? ??:??:??.???: info/<unknown>(<unknown>): displayed com.example.addnewlist/.finallist: +1s140ms ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:14.259 5320: 5320 d/androidruntime ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): shutting down vm ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:14.259 5320: 5320 w/dalvikvm ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): threadid=1: thread exiting uncaught exception (group=0x40a71930) ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:14.290 5320: 5320 e/androidruntime ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): fatal exception: main ??-?? ??:??:??.???: info/<unknown>(<unknown>): java.lang.illegalstateexception: system services not available activities before oncreate() ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.app.activity.getsystemservice(activity.java:4463) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.view.layoutinflater.from(layoutinflater.java:210) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.example.addnewlist.newfriendlist.oncreatedialog(newfriendlist.java:182) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.example.addnewlist.finallist$1.onclick(finallist.java:56) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.view.view.performclick(view.java:4204) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.view.view$performclick.run(view.java:17355) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.os.handler.handlecallback(handler.java:725) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.os.handler.dispatchmessage(handler.java:92) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.os.looper.loop(looper.java:137) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.app.activitythread.main(activitythread.java:5041) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ java.lang.reflect.method.invokenative(native method) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ java.lang.reflect.method.invoke(method.java:511) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ dalvik.system.nativestart.main(native method) ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:14.319 278: 443 w/activitymanager ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): force finishing activity com.example.addnewlist/.finallist ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:14.319 278: 443 w/windowmanager ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): failure taking screenshot (246x410) layer 21025 ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:14.559 278: 295 i/choreographer ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): skipped 40 frames! application may doing work on main thread. ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:14.559 37: 313 e/surfaceflinger ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): ro.sf.lcd_density must defined build property ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:14.887 278: 292 w/activitymanager ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): activity pause timeout activityrecord{413e8ea0 u0 com.example.addnewlist/.finallist} ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:24.373 278: 292 w/activitymanager ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): launch timeout has expired, giving wake lock! ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:24.924 278: 292 w/activitymanager ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): activity idle timeout activityrecord{41024d70 u0 com.example.addnewlist/.newfriendlist} ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:31.718 599: 617 d/exchangeservice ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): received deviceid email app: null ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:31.718 599: 617 d/exchangeservice ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): !!! deviceid unknown; stopping self , retrying ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:36.759 599: 615 d/exchangeservice ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): !!! eas exchangeservice, oncreate ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:36.769 599: 599 d/exchangeservice ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): !!! eas exchangeservice, onstartcommand, startingup = false, running = false ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:36.769 599: 599 d/exchangeservice ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): !!! eas exchangeservice, onstartcommand, startingup = true, running = false ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:36.789 278: 290 w/activitymanager ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): unable start service intent { act=com.android.email.account_intent } u=0: not found ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:36.789 599: 614 d/exchangeservice ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): !!! email application not found; stopping self ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:36.800 278: 442 w/activitymanager ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): unable start service intent { act=com.android.email.account_intent } u=0: not found ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:36.809 599: 599 e/activitythread ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): service com.android.exchange.exchangeservice has leaked serviceconnection com.android.emailcommon.service.serviceproxy$proxyconnection@40cd3578 bound here ??-?? ??:??:??.???: info/<unknown>(<unknown>): android.app.serviceconnectionleaked: service com.android.exchange.exchangeservice has leaked serviceconnection com.android.emailcommon.service.serviceproxy$proxyconnection@40cd3578 bound here ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.app.loadedapk$servicedispatcher.<init>(loadedapk.java:969) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.app.loadedapk.getservicedispatcher(loadedapk.java:863) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.app.contextimpl.bindservice(contextimpl.java:1418) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.app.contextimpl.bindservice(contextimpl.java:1407) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.content.contextwrapper.bindservice(contextwrapper.java:473) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.emailcommon.service.serviceproxy.settask(serviceproxy.java:157) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.emailcommon.service.serviceproxy.settask(serviceproxy.java:145) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.emailcommon.service.accountserviceproxy.getdeviceid(accountserviceproxy.java:116) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.exchange.exchangeservice.getdeviceid(exchangeservice.java:1249) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.exchange.exchangeservice$7.run(exchangeservice.java:1856) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.emailcommon.utility.utility$2.doinbackground(utility.java:551) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.emailcommon.utility.utility$2.doinbackground(utility.java:549) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.os.asynctask$2.call(asynctask.java:287) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ java.util.concurrent.futuretask.run(futuretask.java:234) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1080) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:573) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ java.lang.thread.run(thread.java:856) ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:36.819 599: 599 e/strictmode ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): null ??-?? ??:??:??.???: info/<unknown>(<unknown>): android.app.serviceconnectionleaked: service com.android.exchange.exchangeservice has leaked serviceconnection com.android.emailcommon.service.serviceproxy$proxyconnection@40cd3578 bound here ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.app.loadedapk$servicedispatcher.<init>(loadedapk.java:969) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.app.loadedapk.getservicedispatcher(loadedapk.java:863) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.app.contextimpl.bindservice(contextimpl.java:1418) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.app.contextimpl.bindservice(contextimpl.java:1407) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.content.contextwrapper.bindservice(contextwrapper.java:473) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.emailcommon.service.serviceproxy.settask(serviceproxy.java:157) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.emailcommon.service.serviceproxy.settask(serviceproxy.java:145) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.emailcommon.service.accountserviceproxy.getdeviceid(accountserviceproxy.java:116) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.exchange.exchangeservice.getdeviceid(exchangeservice.java:1249) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.exchange.exchangeservice$7.run(exchangeservice.java:1856) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.emailcommon.utility.utility$2.doinbackground(utility.java:551) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.emailcommon.utility.utility$2.doinbackground(utility.java:549) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.os.asynctask$2.call(asynctask.java:287) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ java.util.concurrent.futuretask.run(futuretask.java:234) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1080) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:573) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ java.lang.thread.run(thread.java:856) ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:36.819 278: 289 w/activitymanager ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): unbind failed: not find connection android.os.binderproxy@4128da70 ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:36.819 599: 599 e/activitythread ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): service com.android.exchange.exchangeservice has leaked serviceconnection com.android.emailcommon.service.serviceproxy$proxyconnection@40cfb5d0 bound here ??-?? ??:??:??.???: info/<unknown>(<unknown>): android.app.serviceconnectionleaked: service com.android.exchange.exchangeservice has leaked serviceconnection com.android.emailcommon.service.serviceproxy$proxyconnection@40cfb5d0 bound here ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.app.loadedapk$servicedispatcher.<init>(loadedapk.java:969) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.app.loadedapk.getservicedispatcher(loadedapk.java:863) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.app.contextimpl.bindservice(contextimpl.java:1418) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.app.contextimpl.bindservice(contextimpl.java:1407) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.content.contextwrapper.bindservice(contextwrapper.java:473) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.emailcommon.service.serviceproxy.settask(serviceproxy.java:157) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.emailcommon.service.serviceproxy.settask(serviceproxy.java:145) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.emailcommon.service.serviceproxy.test(serviceproxy.java:191) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.exchange.exchangeservice$7.run(exchangeservice.java:1850) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.emailcommon.utility.utility$2.doinbackground(utility.java:551) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.emailcommon.utility.utility$2.doinbackground(utility.java:549) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.os.asynctask$2.call(asynctask.java:287) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ java.util.concurrent.futuretask.run(futuretask.java:234) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1080) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:573) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ java.lang.thread.run(thread.java:856) ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:36.839 599: 599 e/strictmode ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): null ??-?? ??:??:??.???: info/<unknown>(<unknown>): android.app.serviceconnectionleaked: service com.android.exchange.exchangeservice has leaked serviceconnection com.android.emailcommon.service.serviceproxy$proxyconnection@40cfb5d0 bound here ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.app.loadedapk$servicedispatcher.<init>(loadedapk.java:969) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.app.loadedapk.getservicedispatcher(loadedapk.java:863) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.app.contextimpl.bindservice(contextimpl.java:1418) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.app.contextimpl.bindservice(contextimpl.java:1407) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.content.contextwrapper.bindservice(contextwrapper.java:473) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.emailcommon.service.serviceproxy.settask(serviceproxy.java:157) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.emailcommon.service.serviceproxy.settask(serviceproxy.java:145) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.emailcommon.service.serviceproxy.test(serviceproxy.java:191) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.exchange.exchangeservice$7.run(exchangeservice.java:1850) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.emailcommon.utility.utility$2.doinbackground(utility.java:551) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ com.android.emailcommon.utility.utility$2.doinbackground(utility.java:549) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ android.os.asynctask$2.call(asynctask.java:287) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ java.util.concurrent.futuretask.run(futuretask.java:234) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1080) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:573) ??-?? ??:??:??.???: info/<unknown>(<unknown>): @ java.lang.thread.run(thread.java:856) ??-?? ??:??:??.???: info/<unknown>(<unknown>): [ 08-08 07:14:36.839 278: 418 w/activitymanager ] ??-?? ??:??:??.???: info/<unknown>(<unknown>): unbind failed: not find connection android.os.binderproxy@4128d2f0
try
@override public void onbackpressed() { showalertdialog(); }
showalertdialog() function
private void showalertdialog() { alertdialog.builder alertdialogbuilder = new alertdialog.builder(checkoutscreenactivity.this); // set title alertdialogbuilder.settitle("confirmation"); // set dialog message alertdialogbuilder.setmessage("message").setcancelable(false).setpositivebutton("yes", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { } }).setnegativebutton("no", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int id) { dialog.cancel(); } }); // create alert dialog alertdialog alertdialog = alertdialogbuilder.create(); // show alertdialog.show(); }
Comments
Post a Comment