Take screenshot programmatically of the whole screen

后端 未结 2 985
滥情空心
滥情空心 2020-12-30 15:10

I\'m taking screenshot as below:

 public static Bitmap takeScreenshot(Activity activity) {  
      View view = activity.getWindow().getDecorView();  
      v         


        
2条回答
  •  难免孤独
    2020-12-30 15:50

    Read somewhere on the forums about another way: -

    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();
    

    You can try that out. Don't know if it works or not, just saved it for a rainy day :P.

    EDIT:

    Found the link to the post - How to take a screenshots?

    User says, screenshots work for him. I think this should suit your requirement.

提交回复
热议问题