How to show a ProgressDialog using intent in Android? -
I have an activity that downloads data from the database. While the activity is working, I want to show progress with Progress Dealog . I use The progress Diaioelaktiviti is: when a new table from the main activity database When the download starts, the ProgressDialog.STYLE_HORIZONTAL because I want to show the actual value. I activity using a
handler to start that displays the progress Deelaog :
effect intended = new Intention (this, progressive program. Specialty class); Personal Handler Handler = New Handler () {@Override Public Zero Management Message (Message Message) {super.handleMessage (msg); If (msg.what == SET_PROGRESS) {intent.putExtra ("action", "show"); Intent.putExtra ("Progress", msg.arg1); Intent.putExtra ("max", msg.arg2); Intent.putExtra ("Message", Sync Message); Intent.putExtra ("Heading", R. String. Pellez_Wight); Intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK); StartActivity; } And if (msg.what == SHOW_PROGRESS) {intent.putExtra ("action", "show"); Intent.putExtra ("title", sync message); Intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK); StartActivity; } And if (msg.what == HIDE_PROGRESS) {intent.putExtra ("verb", "hide"); Intent.putExtra ("Message", ""); Intent.putExtra ("title", ""); Intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK); StartActivity; }}};
public Scl Skrinprogreshndiylog activity (ProgressDialog pd; additional bundle, string action, on @Create public override void (the bundle saved Instansstet) {Suprknkret (saved Instensstet); extra = getIntent (). GetExtras (); PD = new progress Dialaog (this); PdksetProgressStyle (ProgressDialogkSTYLE_HORIZONTAL); Pd .setCancelable (false); pd.setProgress (extras.getInt ( "progress")); pd.setMax (extras.getInt ( "Max")); pd.setMessage (ex tras.getCharSequence ( "message")); pd.setTitle (extras.getString ( "title")); action = extra .getString ( "action"); if (action.equals ( "show")) {pd.show ();} other {Pdkdismiss ();}} @ override public Whoid Ondestoy () {Suprkndestoy ();}}
handler launches a new progressive activation and a new activity is seen. I would like to avoid this. My goal is only showing an activity that displays progressivity with the right values. (I can not make a progress decoction in main activity, I have to find another way. This is some kind of homework, but I need some help). You can use to get data in the background and can display progressors
< Code> // Get the feed! New Progress Task () carry about (); Private Clark Progress Tasks Ascend Tasks and Late; String, Wide, Boolean & gt; {Personal progressive dialogue = new progressivity (homeactivity.es); / ** Progress dialog to show that the user has backup processing * / ** ** Application Reference * / Prerexecute Secure void () {this.dialog.setMessage ("Please Wait"); This.dialog.show (); } Protected Boolean doInBackground (Last String ... Args) {try to get RSS feed from URL / / utilities.arrayRSS = objRSSFeed .FetchRSSFeeds (Constants.Feed_URL); Back true; } Hold (exception e) {Log.e ("tag", "error", e); return false; }} Safe Zero at the @OverridePostExecute (Ultimate Boolean Success) {if (showing dialog.is ()) {dialog.dismiss (); } If (success) {// display UI update display (); }}}
Comments
Post a Comment