我在 Android 上使用新的 Google+ 应用程序时遇到了一个似乎在网上找不到的技术问题.即时上传如何挂钩到原生相机应用程序?
I was playing around with the new Google+ application on the Android and I had a technical question that I couldn't seem to find online. How does the instant upload hook into the native camera application?
我可以打开 Google+ 应用程序中的一项功能,我使用本机相机应用程序拍摄的任何照片都会自动上传到 Google+ 上的私人相册.无论 Google+ 应用程序当前是否正在运行,这似乎都是正确的.是否有任何类型的钩子可以在我的应用程序中注册回调事件以访问刚刚拍摄"的图片以获得一些后期处理的好处?我真的很想为我目前正在编写的应用程序利用此功能.
I can turn on a feature in the Google+ application and any pictures that I take with the native camera app are automatically uploaded to a private album on Google+. And this seems to be true whether the Google+ application is currently running or not. Is there any type of hook that I can register a callback event for in my application to access "just-taken" pictures for some post-processing goodness? I'd really like to tap into this functionality for an application that I am currently writing.
非常感谢任何正确方向的见解或提示!谢谢!
Any insight or hints in the right direction are greatly appreciated! Thanks!
不完全确定 Google+ 是如何做到的,但一种可行的方法是使用 ContentObserver 接口:抓取 MediaStore.Images.Media ContentProvider
并附加一个 ContentObserver
到它.每当添加相机图像时,您都会收到通知,您可以进行相应处理(包括上传).
Not entirely sure exactly how Google+ does it, but one way that would work is to use the ContentObserver interface: grab the MediaStore.Images.Media ContentProvider
and attach a ContentObserver
to it. Anytime a camera image is added, you'll get a notification and you can process it accordingly (including uploading).
同样的技术适用于几乎所有能够正确处理 ContentObserver
的 ContentProvider
(我假设都是 ContentProvider
,但是你永远无法分辨).
Same technique would work for just about any ContentProvider
that properly handles ContentObserver
s (which I'm assuming is all ContentProvider
s, but you never can tell).
这篇关于Android -- Google+ 即时上传如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!