deepak
deepak

Reputation: 1378

Detecting photo action in android

Hey I'm stuck with this problem for quite a while
I need to have a backround activity in android which will be running to detect any photo/video activity, the minute a photo or video is taken it should make an entry into a text file:

The entry should look like this : [uri_of_new_photo, time, gps-location]

What are the possible ways in which i can achieve this, I was looking at the BroadcastReciever, but was not sure if that would work.

Are there any tutorials/links which can give me a solution. A direct solution to this problem would be great!! (rather than alternatives, as this is a small part of a bigger project)

Upvotes: 1

Views: 78

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006674

What are the possible ways in which i can achieve this

Technically, it's not possible. Anyone is welcome to write a camera application that takes photos or videos and does not tell you about them.

I was looking at the BroadcastReciever, but was not sure if that would work.

I am not sure what "the BroadcastReceiver" is that you are referring to.

You are welcome to use FileObserver to try to monitor likely places for photos and recorded videos. However, there is no guarantee that apps will write their photos or recorded videos in the places that you are looking. And, just because there is a new file in one of those directories does not mean that the user took a photo or recorded a video -- they could have simply copied a file into that directory, or obtained the file from the Internet (e.g., Flickr sync). And, this will only work while your app is running.

You are welcome to use a ContentObserver on MediaStore. It will suffer from the same basic problems as would the FileObserver approach that I mentioned.

If you want to reliably log information about the time and location of photos and videos, write your own camera app.

Upvotes: 1

Related Questions