如何创建一个自动上传的安卓图片应用程序? [英] How to create an auto-upload Android picture app?

查看:36
本文介绍了如何创建一个自动上传的安卓图片应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个自动将图片上传到我的服务器的应用.这个想法是用户使用本机/普通相机创建图片,我的应用会收到通知(捕捉事件)并上传图片(在后台).

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).

我找到了适用于 Windows Phone 的解决方案 (看这里),但不适用于 Android.我怎样才能做到这一点?- 这在技术上是可能(使用给定的 API)还是仅适用于合同服务的特殊功能(Facebook 或 Dropbox 这样做)?

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)?

谢谢!

推荐答案

现在我不相信会为其他活动可以收听的相机捕获事件触发广播.

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

但这是你可以做的.为 "android.intent.action.CAMERA_BUTTON" 声明一个意图过滤器并为其提供最高优先级 - 999

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

这将为您提供本地相机触发的广播的句柄.但是,这会从本机应用程序窃取广播.因此,您可能必须自己处理保存文件,或者制定一个 hack 以将控制权交还给本机应用程序.

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.

经过进一步检查,有更好的方法.收听 android.media.action.IMAGE_CAPTURE 会产生更好的结果,并且应该完全符合您的要求.

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.

这篇关于如何创建一个自动上传的安卓图片应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆