android - Avoid locking the screen while ProgressDialog is displaying -
i want show progressbar while instructions execute in background, don't want lock screen. code locking screen:
private class convertdatainbackground extends asynctask<params, void, boolean> { private myprogressdialog mprogressdialog; @override public void onpreexecute() { if(mprogressdialog == null) mprogressdialog = myprogressdialog.show(mactivity, null, null); } @override protected boolean doinbackground(params...params) { boolean conversionresult = executeconversion(params[0].item1, params[0].item2, params[0].item3); return conversionresult; } @override protected void onpostexecute(boolean result) { try { if(mprogressdialog.isshowing()) mprogressdialog.dismiss(); if(result) { toast toast = toast.maketext(mactivity, r.string.conversion_result, toast.length_short); toast.setgravity(gravity.center, 0, 0); toast.show(); } } catch (exception e) { e.printstacktrace(); } } } execution of instruction in background may take while, , want user able work interface. know anyway can work interface, while progressdialog displaying @ top?
dialogs in android modal. can try creating dialog adding flag_not_touch_modal window parameters - i'm not sure if work. idea behind this:
progressdialog dialog = new progressdialog(this); dialog.setmessage(...); dialog.settitle(...); dialog.getwindow().addflags(windowmanager.layoutparams.flag_not_touch_modal); note @ same time may easier add progressbar activity's layout , show when needed instead of creating dialog - is, in fact, google documentation recommends. android developer's guide on dialogs has say:
avoid progressdialog
android includes dialog class called
progressdialogshows dialog progress bar. however, if need indicate loading or indeterminate progress, should instead follow design guidelinesprogress & activity, useprogressbarin layout.
Comments
Post a Comment