問題描述
我在 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+ 即時上傳如何工作?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!