Does anyone knows how to use notification icon in status bar when downloading a file? Just like when you are downloading a file in app store. The icon is like in gif.
Asked
Active
Viewed 6,357 times
3 Answers
33
Just use the default android resource android.R.drawable.stat_sys_download
for this.

flx
- 14,146
- 11
- 55
- 70
-
1Works great but I needed to add `setTicker("")` for the animation to play. Credit goes to [this answer](http://stackoverflow.com/a/15311161/1276636). – Sufian Mar 04 '15 at 13:13
-
What can i do if downloading is completed? – Pratik Butani May 10 '15 at 15:25
-
1I have done with this `mBuilder.setSmallIcon(android.R.drawable.stat_sys_download_done);` – Pratik Butani May 10 '15 at 17:12
4
Here's a fully functioning example that will show the default "system" download notification icon in the status bar.
private static void showProgressNotification(Context context, int notificationId, String title, String message)
{
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
mBuilder.setContentTitle(title)
.setContentText(message)
.setSmallIcon(android.R.drawable.stat_sys_download)
.setTicker("")
.setProgress(0, 0, true);
manager.notify(notificationId, mBuilder.build());
}
And when your "download" operation is done, clear the notification:
private static void hideProgressNotification(final NotificationManager manager, final Context context, final int id)
{
manager.cancel(id);
}

DiscDev
- 38,652
- 20
- 117
- 133
0
Take a look to Android Download Manager. It shows a notification icon indicating that there are files downloading. Android Download Manager

osayilgan
- 5,873
- 7
- 47
- 68