How to create an auto-upload Android picture app?

2019-02-19 06:21发布

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!

1条回答
干净又极端
2楼-- · 2019-02-19 07:00

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.

查看更多
登录 后发表回答