2

I am trying to create an app that automatically uploads a picture to my server. The idea is that a user creates a picture with the native/normal camera and my app gets a notification (catches the event) and uploads the picture (in the background).

I found a solution for Windows Phone (see here), but not for Android. How can I do this? - Is this technically even possible (with the given APIs) or is it a special feature just for contracted services (Facebook or Dropbox do that)?

Thank you!

casaout
  • 1,819
  • 3
  • 24
  • 54
  • 1
    Hi Samarth. I am not sure how I can improve my question as I am not sure if my idea is even possible because I couldn't find a similar answer in a forum or a hint in the documentation. Just the fact, that some famous apps (like Facebook, Dropbox) already do this and that it's possible on the Windows Phone platform. Therefore, I think this post indeed has value to the community... Thanks. – casaout May 24 '13 at 19:41
  • Yes it is possible. Camera returns intents with bitmaps. Which you can send to your server with HTTP request. It is upto you to encode/decode the bitmap while sending from the app and retrieving it on your server. – Sam May 24 '13 at 19:45
  • Thanks. I think I could manage to upload the picture (bitmap) to the server as there are a lot of resources and tutorial on this stuff available. But how do I know on Android and iOS when a user took a picture (i.e. how can I get the event or make the background uploader start)? - Thank you! – casaout May 24 '13 at 19:49

1 Answers1

1

Right now i don't believe there is a Broadcast that is fired for a camera capture event that other activities can listen to.

But here's what you can do. Declare an intent filter for "android.intent.action.CAMERA_BUTTON" and provide it the highest priority - 999

This will give you a handle on the broadcast fired by the native camera. However this would steal the broadcast from the native app. So you might have to handle saving the file yourself, or formulate a hack to give back control to the native app.

Don't know if there is a better way. Also can't say much about the use-case of third-party cameras.

EDIT:

On further inspection, there is a better way. Listening to android.media.action.IMAGE_CAPTURE would yield better results and should fit right into your requirements.

Sam
  • 3,413
  • 1
  • 18
  • 20
  • Hi Samarth. Thank you for your post. This sounds interesting. Is that right that I can register an Intent as an event trigger and my app would receive such an event if a new picture has been taken? It could then handle the picture stuff (i.e. upload it to the server) in the background? I also found some useful information about this here: http://www.vogella.com/articles/AndroidIntent/article.html – casaout May 25 '13 at 05:36
  • The best way to find out would be to try it out yourself. I have never listened for this intent before. In theory it should work. And yes that tutorial will help you out on how to consume intents if you are new to android. You can also look up those intents on developer.android.com to know about their specific quirks/ usages. – Sam May 25 '13 at 05:42
  • Ok thanks. I am now primarily checking out what is possible on what platform and therefore am happy to know that it works in theory. Thanks again for your help! – casaout May 25 '13 at 05:44