Is there any way to use the following code to take pictures automatically i.e. no button clicks at all. Just after sometime image can be taken automatically and stored on the SD card.
protected void startCameraActivity() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(new File(file_name)));
startActivityForResult(intent, 1);
finish();
}
No, once you start an Intent you really have no control over the Activity you start (assuming it's not one that you wrote yourself). In your case, you have to make your own Activity and use the Camera API.
Check out this tutorial:
http://marakana.com/forums/android/examples/39.html
You can use Timer
& TimerTask
Class together for your requirement. Just study the following code and modify it according to your usage.
import java.util.Timer;
import java.util.TimerTask;
class MyTimerTask extends TimerTask
{
public void run()
{
// Put your camera capturing and photo saving code here
}
}
public class MainClass
{
public static void main(String args[])
{
MyTimerTask myTask = new MyTimerTask();
Timer myTimer = new Timer();
/*
* Set an initial delay of 15 second, then repeat every 10 second.
*/
myTimer.schedule(myTask, 15000, 1000);
}
}