tags:

views:

1720

answers:

3

Hi,

I'd like my app to upload an image to a web server. That part works.

I'm wondering if it's possible to somehow show the progress of the upload by entering an entry in the "notification bar". I see the Facebook app does this.

When you take a picture and choose to upload, the app lets you continue on, and somehow puts the picture upload notifications in a progress bar in the notification bar. I think that's pretty slick. I guess they spawn a new service or something to handle the upload and update that progress bar in the notification bar every so often.

Thanks for any ideas

A: 

I'm not a Facebook user, so I do not know exactly what you're seeing.

It is certainly possible to keep updating a Notification, changing the icon to reflect completed progress. As you suspect, you would do this from a Service with a background thread that is managing the upload.

CommonsWare
Agreed, I guess I'm wondering what API they used to put their progress bar in the notifications bar - the global UI panel you can slide down with your finger which shows download progress from marketplace etc. It seems that panel is external to the app yet they are able to put their progress bar in there?Thanks
Mark
Well, that's how notifications work... you send them with the notification platform service, and they'll appear in that panel. As Klondike said, you can render any view as the notification body, so no magic here. The more interesting question is how to get progress information from a photo upload. You'd need to break down your upload into chunks and upload them one by one. Sounds like a lot of work for a pretty useless effect. I mean, who in their right minds would keep staring at a progress bar in a notification...
Matthias
That was directed @Mark
Matthias
@Matthias: it's easier to do this if you ask fresh questions (honest! SO can handle the load! :-) Anyway, I think HttpClient can tell you progress upload on the fly. http://stackoverflow.com/questions/254719/file-upload-with-java-with-progress-bar has info for the 3.x API, not Android's 4.x, but the concepts probably hold.
CommonsWare
@commonsware Good to know, thanks for the pointer
Matthias
+3  A: 

You can design a custom notification, instead of just the default notification view of header and sub-header.

What you want is here: http://developer.android.com/guide/topics/ui/notifiers/notifications.html#CustomExpandedView

Klondike
A: 

For a more detailed explanation how to create custom views see: http://developer.android.com/guide/topics/ui/notifiers/notifications.html

tony