Android Question get screenshot (rooted)

Discussion in 'Android Questions' started by peacemaker, Apr 6, 2015.

  1. peacemaker

    peacemaker Well-Known Member Licensed User

    How to get screenshot Bitmap on a rooted device ?

    Code:
    private void captureScreen() {
            
    View v = getWindow().getDecorView().getRootView();
            v.setDrawingCacheEnabled(
    true);
            
    Bitmap bmp = Bitmap.createBitmap(v.getDrawingCache());
            v.setDrawingCacheEnabled(
    false);
            
    try {
                FileOutputStream fos = new FileOutputStream(new 
    File(Environment
                        .getExternalStorageDirectory().toString(), 
    "SCREEN"
                        + System.currentTimeMillis() + 
    ".png"));
                bmp.compress(CompressFormat.PNG, 
    100, fos);
                fos.flush();
                fos.close();
            
    } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    Please, help to get Bitmap, no file saving is needed.
     
  2. DonManfred

    DonManfred Expert Licensed User

  3. peacemaker

    peacemaker Well-Known Member Licensed User

    Screenshot not by my app is needed, any other app on the rooted device.
     
  4. DonManfred

    DonManfred Expert Licensed User

    The code you provided does nothing others. It must be part of an running activity so everything it will capture will be the screenshot of the own app.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice