0
我无法使用getWindow
内部服务查看。如何获取应用程序之外的任何屏幕的视图?
我将此视图用于外部应用程序的任何屏幕。
View v1 = getWindow().getDecorView().getRootView();
如何在服务中捕获屏幕截图?
或者我如何获得外部应用程序之外的任何屏幕的视图?
我无法使用getWindow
内部服务查看。如何获取应用程序之外的任何屏幕的视图?
我将此视图用于外部应用程序的任何屏幕。
View v1 = getWindow().getDecorView().getRootView();
如何在服务中捕获屏幕截图?
或者我如何获得外部应用程序之外的任何屏幕的视图?
冲床线:你在提问时很不好。
但我会尽力回答我明白的问题。
如何截屏?
private void getScreenshot() {
try {
String imagePath = Environment.getExternalStorageDirectory().toString() + "/" + /*NAME*/ + ".jpg";
View view = getWindow().getDecorView().getRootView();
view.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache());
view.setDrawingCacheEnabled(false);
File imageFile = new File(imagePath);
FileOutputStream outputStream = new FileOutputStream(imageFile);
int quality = 100;
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
outputStream.flush();
outputStream.close();
} catch (Throwable e) {
e.printStackTrace();
}
}
现在就做你想做的事。
而且我不明白你要问什么,
View v1 = getWindow().getDecorView().getRootView();
可以进一步,如果你想澄清。
请阅读这些:[page1](http://stackoverflow.com/help/how-to-ask)[page2](http://stackoverflow.com/help/mcve)[page3](http:/ /stackoverflow.com/help/on-topic) –