[英]Get di screenshot of the display
Is it possible to get a screenshot of the display at any time with a background service.是否可以通过后台服务随时获取显示屏幕截图。 This code enable only to capture the screenshot of my activity.此代码仅允许捕获我的活动的屏幕截图。
View v1 = getWindow().getDecorView().getRootView();
v1.setDrawingCacheEnabled(true);
bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
Thanks.谢谢。
To get screenshot of views not belonging to the app developed by you, use MediaProjectionManager .要获取不属于您开发的应用程序的视图的屏幕截图,请使用MediaProjectionManager 。
But you have to first take the permission of the user to do so.但是您必须首先征得用户的许可才能这样做。
Note: This is applicable for Android 5.0(Lolipop) onwards.注意:这适用于 Android 5.0(Lolipop) 以上版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.