当前位置:   article > 正文

Android 一体机等root后的机器指令截屏

Android 一体机等root后的机器指令截屏
import com.blankj.utilcode.util.ShellUtils;
public void takeScreenShot() {
    String savedPath = createImageFile().getAbsolutePath();
    try {
        String cmd = "screencap -p " + savedPath;
        ShellUtils.execCmd(cmd,true);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

private File createImageFile(){
    try {
        String imageFileName = "AI_SD_SCREEN_IMAGE";
        File storageDir = BaseActivity.getContext().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
        File image = new File(storageDir+"/"+imageFileName+".png");
        if(image.exists()){
            image.delete();
            boolean newFile = image.createNewFile();
        }
        return image;
    }catch (Exception e){
        Log.e("111",e.getMessage());
    }
    return null;
}
本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号