user2983308
user2983308

Reputation: 11

Programmatically screenshot when camera is live on surface view in Android

I want to take screen shot programmatically in android when camera is live on surface view, I have also inflated multiple layouts on over surface view but when I'm trying to take screen shot programmatically then screenshot has been taken but issue is stay there one that is screenshot is black view means my picture which is live on surface view that not appear in screen shot.

Upvotes: 1

Views: 1090

Answers (1)

vanste25
vanste25

Reputation: 1774

Have you tried something like this:

Process sh = Runtime.getRuntime().exec("su", null,null);
OutputStream  os = sh.getOutputStream();
os.write(("/system/bin/screencap -p " + "/sdcard/img.png").getBytes("ASCII"));
os.flush();

Ofcourse, this works only if your device is rooted.

Read this: https://stackoverflow.com/a/14718588/1374065

Upvotes: 1

Related Questions