Skip to content Skip to sidebar Skip to footer

Take Screenshot Of Whole Screen

I have seen a lot of code snippets for taking a screenshot but was not able to get something which takes the screenshot of the whole screen and not just a view. It should replicate

Solution 1:

There is an Android Screenshot library, which is available here. There wiki pages says library can be used to take screenshot of entire screen without the need of root level access, even from an unsigned application. I have never tried it though. You can use it as a starting point.

Solution 2:

        sh = Runtime.getRuntime().exec("su", null, null);
        System.out.println("capturing");
        OutputStream outputstream = sh.getOutputStream();
        outputstream.write("/system/bin/screencap -p /sdcard/tos_processing.png".getBytes("ASCII"));
        outputstream.flush();
        outputstream.close();
        sh.waitFor();
        System.out.println("captured");
        bitmap = BitmapFactory.decodeFile("/sdcard/tos_processing.png");

Solution 3:

Try this it worked for me...

@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        view = (ImageView) findViewById(R.id.ImageView01);
        ButtonmyBtn= (Button) findViewById(R.id.Button01);
        myBtn.setOnClickListener(newView.OnClickListener() {

            @OverridepublicvoidonClick(View v) {

                Viewv1= view.getRootView();

                v1.setDrawingCacheEnabled(true);

                Bitmapbm= v1.getDrawingCache();
                BitmapDrawablebitmapDrawable=newBitmapDrawable(bm);

                ImageViewview2= (ImageView) findViewById(R.id.ImageView01);

                view2.setBackgroundDrawable(bitmapDrawable);
            }
        });
}

Post a Comment for "Take Screenshot Of Whole Screen"