0

I am developing an android application which requires use of android camera api. I am successfully able to caputre the image and save it. Now I want the camera application to close in about 2 minutes if the user is not clicking any image, saving or making any activity

Ravi Rawal
  • 233
  • 3
  • 14

1 Answers1

0

You can do that very easily.

Handler based approach

 Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            // Stop the camera
        }
    },120000);

Some other approches

  1. pick any view use postRunnable method on it which takes runnable and timestamp after what runnable has to run.

  2. Timer based approach.

  3. Countdown Timer Based approach
  4. Thread (sleep for 1 second or some unit ) and Handler based based approach
Sush
  • 3,864
  • 2
  • 17
  • 35
  • i think the op is triggering the android camera app, which is an activity not owned by the invoking app. How will you close that activity when your app is in paused state ? – Prasad Pawar Dec 14 '15 at 05:38
  • @PrasadPawar Your correct. But App is not paused state, camera firing Activity is paused state and it can trigger the any other activity. pause state is too stop the data rendering or fetching actions. Timer based logics can be used. – Sush Dec 14 '15 at 05:53
  • yes that's right. So, basically the camera app has to have a timer right? so the OP will have to develop his own module for image capture & use the timer logic. – Prasad Pawar Dec 14 '15 at 07:00