Java android:如何通过编程获得整个屏幕的截图
下面是截图的代码。。但问题是它只需要应用程序的屏幕截图。。不是整个屏幕(返回和主页按钮和通知栏) 有什么方法可以让我拍摄整个屏幕的截图而不仅仅是应用程序Java android:如何通过编程获得整个屏幕的截图,java,android,screenshot,Java,Android,Screenshot,下面是截图的代码。。但问题是它只需要应用程序的屏幕截图。。不是整个屏幕(返回和主页按钮和通知栏) 有什么方法可以让我拍摄整个屏幕的截图而不仅仅是应用程序 private void takeScreenshot() { Date now = new Date(); android.text.format.DateFormat.format("yyyy-MM-dd_hh:mm:ss", now); try { // image namin
private void takeScreenshot() {
Date now = new Date();
android.text.format.DateFormat.format("yyyy-MM-dd_hh:mm:ss", now);
try {
// image naming and path to include sd card appending name you choose for file
String mPath = Environment.getExternalStorageDirectory().toString() + "/" + now + ".jpg";
// create bitmap screen capture
View v1 = getWindow().getDecorView().getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
File imageFile = new File(mPath);
FileOutputStream outputStream = new FileOutputStream(imageFile);
int quality = 100;
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
outputStream.flush();
outputStream.close();
// openScreenshot(imageFile);
} catch (Throwable e) {
// Several error may come out with file handling or DOM
e.printStackTrace();
}
}
你检查过这个了吗看看ImageReader