赞
踩
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; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。