问题
Basically I want to set a Broadcastreceiver
that gets triggered when the user downloads an image into gallery/phone from chrome, facebook, twitter..etc
when the photo is finished downloading , and the actions is triggered, I want access to the downloaded image for extra work such as editing and stuff..!
I'm thinking this can be accomplished by Broadcastreceiver
, that listens for the image and then do the actions that needed..!
I've tried to search for action to be added in the Manifest
inside the receiver intent-filter
, but I don't which one?
<receiver
android:enabled="true"
android:exported="true"
android:name=".MyReceiver">
<inent-filter>
<action android:name="??????"/>
</inent-filter>
I've read almost all the intent action here, but couldn't find the one..!
回答1:
Older android versions used
<receiver
android:name=".NewPictureReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.hardware.action.NEW_PICTURE" />
<data android:mimeType="image/jpeg" />
</intent-filter>
</receiver>
to get informed that the camera has shot a new photo. I do not know if this get also triggered by a downloaded image.
taken from https://github.com/M66B/FineGeotag/ that adds gps data to jpg
This will not work any more with newer android version.
Not a working solution but some hints how to find a solution.
The android media scanner updates the android internal media database and you can register an image-contentprovder-observer that tells your that media database MediaStore.Images.Media.EXTERNAL_CONTENT_URI
has changed. you can query then the media db order by last modify date descending
. The top rows should be the new images.
来源:https://stackoverflow.com/questions/44435699/broadcastreceiver-for-a-downloaded-image