简体   繁体   English

如何通过在 android 中显示 android 来获取屏幕截图

[英]How to get a screenshot via display android in android

I need to get a screenshot of when the application is minimized我需要获取应用程序最小化时间的屏幕截图

This code a grab screenshot from rootView of application activity:这段代码是来自应用活动的rootView的抓取屏幕截图:

View v1 = getWindow().getDecorView().getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap original = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);

How to get a screenshot from the display, and not from the activity view?如何从显示器而不是从活动视图中获取屏幕截图?

there is an API dedicated for screenshots/recordings called MediaProjection, some doc in HERE有一个 API 专门用于称为 MediaProjection 的屏幕截图/录音, 这里有一些文档

sample projects in HERE and HERE HEREHERE中的示例项目

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM