UI Thread on Android Device 2.3

Asked By 0 points N/A Posted on -

I want to perform a function that can download files in the background.

I will be using UI thread on Android Device with version 2.3.

I want it to be like a notification area with customized progress bar.

How can I do that? Can someone please help me with it? Thank you in advance. 

Answered By 0 points N/A #160779

UI Thread on Android Device 2.3


Kindly follow the instructions below regarding the function that you would like to create:

1. You may need to create a notification first.

2. You need to create a notification which has a customized layout that contains a Progress Bar. After you created the Notification, you should use it to update your ProgressBar via

notification.contentView.setProgressBar (R.id.yourprogessbar, 100, 42, false); nm.modify (notificationId, notification);

Those information are basically for the UI-side. So to download a file in the background, follow the instructions on number

3. You need to use AsyncTask.publishProgress() to send download progress updates to the UI-thread and update your progress bar inside AsyncTask.onProgressUpdate()

If you are only supporting API Level 9 and higher, you can actually use DownloadManager, which handles all of this for you since this is already available for Android 2.3. This service allows you to download in the background by specifying a download destination on external storage since the default is on Downloads Storage.

I hope the information I provided answered your questions.

Login/Register to Answer

Related Questions