Skip to content Skip to sidebar Skip to footer

Android- Status Bar Notification With Progress Bar

I currently have a status bar notification that goes off when an mp3 is downloaded from a url. It launches fine (and the file does download fine), however, the progress bar doesn't

Solution 1:

http://developer.android.com/training/notify-user/display-progress.html

This will work for you until the app is running on foreground. If the app stops the progress bar gets stuck. Its better to download using a service


Solution 2:

Try the following -

    public class DownloadFile extends AsyncTask<String, Integer, String>{
    ProgressDialog pd;

    public DownloadFile() {
    super();
    pd = ProgressDialog.show(context, "Loading..", "Doing Stuff", true,false);
    }

    @Override
    protected String doInBackground(String... url) {
        //stuff
    }


    @Override
    protected void onPostExecute (Boolean result){

    pd.dismiss();

    }


}

Post a Comment for "Android- Status Bar Notification With Progress Bar"