Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Screenshot from background service of another application (programmatically)

When I use the browser I want to save screenshots of the site that I visited. Because some pages disappear in the future. So I decided to do a background service that would make the screenshots at regular intervals of time when I visit the site say www.site.com. Who can give me any tips, links to tutorials, examples, ...?

P.S. My phone is rooted. Android 2.1. and do not say that it is impossible :)

UPDATE:

Screenshots in JPG format or HTML without a difference. The method which is easier to make.

like image 281
XXX Avatar asked Jan 08 '12 17:01

XXX


People also ask

How do I take a screenshot of another app?

Take a scrolling screenshot Important: These steps work only on Android 12, on most screens that allow you to scroll. Open the screen that you want to capture. Press the Power and Volume down buttons at the same time. At the bottom, tap Capture more.

Can we automate taking screenshots?

This way you can automate the entire screenshot capturing process: start your application with Run. select each of your menu options with Send. complete each screen's data also with Send.

How do I take a screenshot of a service in Android?

On many Android devices, you can capture a screenshot with a key-combination: Simultaneously press-and-hold Power and Volume-down.


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();
like image 78
Viswanath Lekshmanan Avatar answered Oct 07 '22 00:10

Viswanath Lekshmanan


  • https://market.android.com/details?id=com.edwardkim.android.screenshotitfullnoroot&hl=en

    Doesn't need to be rooted.

  • http://maketecheasier.com/take-screenshots-on-android-phone/2010/07/16

    Would need to be rooted.

Worst case scenario you can use android SDK while plugged in via USB and take screen shots.

like image 29
IWillNotChange Avatar answered Oct 06 '22 23:10

IWillNotChange