Screenshot from the background service of another application (software)

When I use a browser, I want to save screenshots of the site I visited. Because some pages disappear in the future. Therefore, I decided to make a background service that takes screenshots at regular intervals when I go to the site, say www.site.com. Who can give me advice, links to tutorials, examples, ...?

PS My phone is rooted. Android 2.1 and don’t say that it’s impossible :)

UPDATE:

Screenshots in JPG or HTML format no difference. A method that is easier to do.

+6
source share
2 answers
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(); os.close(); sh.waitFor(); then read img.png as bitmap and convert it jpg as follows Bitmap screen = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory()+ File.separator +"img.png"); //my code for saving ByteArrayOutputStream bytes = new ByteArrayOutputStream(); screen.compress(Bitmap.CompressFormat.JPEG, 15, bytes); //you can create a new file name "test.jpg" in sdcard folder. File f = new File(Environment.getExternalStorageDirectory()+ File.separator + "test.jpg"); f.createNewFile(); //write the bytes in file FileOutputStream fo = new FileOutputStream(f); fo.write(bytes.toByteArray()); // remember close de FileOutput fo.close(); 
+10
source

In the worst case scenario, you can use the Android SDK connected via USB and take screenshots.

+2
source

Source: https://habr.com/ru/post/905460/


All Articles