开发者

Listen to photo taken event

开发者 https://www.devze.com 2023-04-01 17:29 出处:网络
Just want to register to video/photo taken events. Hopefully, but not a must, the event will be triggered when the operation have finished, so I won\'t process half photos or half taken videos.

Just want to register to video/photo taken events.

Hopefully, but not a must, the event will be triggered when the operation have finished, so I won't process half photos or half taken videos.

Already tried:

fileObserver 开发者_JS百科= new FileObserver(dcimDir, FileObserver.ALL_EVENTS)

I see the events when traversing using a file manager app but not when a picture is taken nor when copying.

Ideas?


Found a way by registering to all sub directories of dcim (except the ones that start with a period):

new FileObserver(dcimDir.toString(), FileObserver.CLOSE_WRITE)

The reason I need to register to all of them is because different phones put picutes and videos in different folders - at least they are all under DCIM.

The reason the event is 'CLOSE_WRITE' is because I want to trigger after the photo/video is complete, so I won't process only half of the photo/video.


There is another way: ContentProvider

See another SE thread for more info: Android -- How does Google+ instant upload work?

0

精彩评论

暂无评论...
验证码 换一张
取 消