[英]I want to start a service only when a new picture is clicked in android. How do I go about doing that?
I want to start a service only when a new picture is captured from the phone camera in android. 我只想从android中的手机摄像头捕获新图片时才启动服务。 How do I go about doing that?
我该怎么做? Currently, I am running a background task that runs every 3 seconds to check if a new picture has been clicked.
当前,我正在运行一个后台任务,该任务每3秒运行一次,以检查是否单击了新图片。
You can have tracks for image clicks then check those tracks every 3 seconds. 您可以为图像单击提供音轨,然后每3秒检查一次这些音轨。
final boolean hasClicked = false;
new View.OnClickListener() { //image onclick listener
hasClicked = true;
}
new Timer.schedule(new TimerTask() {
if ( hasClicked ) {
// start your service
}
}, 3000, 3000);
If you need to track how many times the user clicked the image before the interval you can make a counter for it. 如果您需要跟踪间隔之前用户单击图像的次数,则可以为其计数。 be careful about the spam clicks.
注意垃圾邮件的点击。
当前没有用于记录和监视摄像机活动的API,可能出于隐私和安全原因
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.