Android - progress dialog for an "syncronous" task -
when app used first time performing data setup etc takes "random" time complete, whilst going on i'm showing progress dialog user telling them whats going on , presenting spinning wheel, done via async task many docs , guides way go using progress dialog.
but problem need else in app "wait" data setup finished before goes business still keep handy dialog telling user whats going on, im struggling find how go this.
if has ideas great.
you can use threads doing data setup , , handlers implementation after work in thread over..
see below
progressdialog pd = progressdialog.show(this,"please wait..", "data setup in progress..", false, true); pd.setcanceledontouchoutside(false); thread tdatasetup = new thread( new runnable() { @override public void run() { //insert data setup code here.. if(datasetupdone) handlerdatasetup.sendemptymessage(operation_completed); else handlerdatasetup.sendemptymessage(operation_not_completed); } }); tdatasetup.start(); private handler handlerdatasetup = new handler() { @override public void handlemessage(message msg) { if(pd.isshowing()) { pd.dismiss(); } if(msg.what == operation_completed) //code after data setup done , implemented here.. else if(msg.what == operation_not_completed) //code if data setup fails.. } };
Comments
Post a Comment