听合影留念事件 [英] Listen to photo taken event

查看:125
本文介绍了听合影留念事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是要注册到视频/照片拍摄的事件。

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.

已经尝试过:

fileObserver = 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.

想法?

推荐答案

通过注册到DCIM的所有子目录(但用了一段开始的)找到了一个方法:

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)

我需要注册到所有这些的原因是因为不同的手机放在picutes和视频在不同的文件夹 - 至少他们都在DCIM

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.

究其原因,事件是CLOSE_WRITE'是因为我想要的照片后触发/影片完成,所以我不会只处理照片/视频的一半。

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.

这篇关于听合影留念事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆