要获得截图中,你需要得到视图
getWindow().getDecorView();
缓存视图为位图的根布局
public static File getScreenShot(Context context,View parentLayout)
{
parentLayout.setDrawingCacheEnabled(true);
Bitmap cachedBitmap= parentLayout.getDrawingCache();
Bitmap finalBitmap = cachedBitmap.copy(Bitmap.Config.RGB_565, true);
return saveBitmap(context,finalBitmap);
}
保存位图中的设备或这种
private static File saveBitmap(Context context,Bitmap bitmap)
{
File snapShot=null;
try
{
String cacheDirectory=getCacheDirectory(context);
snapShot=new File(cacheDirectory, "Screenshot.png");
FileOutputStream out = new FileOutputStream(snapShot);
bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
out.close();
} catch (Exception e)
{
e.printStackTrace();
}
return snapShot;
}
是这个程序刺探你的用户吗?我相信你应该首先检查这项任务是否符合道德标准。 –