0

I want to start a service only when a new picture is captured from the phone camera in 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.

ankuranurag2
  • 2,300
  • 15
  • 30

2 Answers2

0

You can have tracks for image clicks then check those tracks every 3 seconds.

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.

Lorence Hernandez
  • 1,189
  • 12
  • 23
  • This is what I am already doing. I need to know how can i add a trigger to the camera(dcim) folder so that my service fires whenever a new image is added to it. – Aman Agarwal Feb 19 '19 at 04:34
0

There are currently no APIs for logging and monitoring camera activity, probably for privacy and security reasons

Safu Harry
  • 11
  • 4