How to capture image/ images secretly using camera without user interaction? I want to make a spy app so that it can take image/ images without any user interaction? Is it possible? Please someone help me.
Asked
Active
Viewed 431 times
-5
-
1Ethics of creating such an app aside, this question is too broad for the scope of SO. Please take a look at [What topics can I ask about here?](http://stackoverflow.com/help/on-topic) – Michael Dodd May 16 '17 at 14:17
1 Answers
0
Use below code:
private void takePhoto()
{
SurfaceView surface = new SurfaceView(this);
Camera camera = Camera.open();
try {
camera.setPreviewDisplay(surface.getHolder());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
camera.startPreview();
camera.takePicture(null,null,jpegCallback);
}
PictureCallback jpegCallback = new PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera)
{
FileOutputStream outStream = null;
try {
String dir_path = "";// set your directory path here
outStream = new FileOutputStream(dir_path+File.separator+image_name+no_pics+".jpg");
outStream.write(data);
outStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally
{
camera.stopPreview();
camera.release();
camera = null;
}
}
};

Andrey Zhukov
- 76
- 6