Android屏幕录制提示
创始人
2024-10-09 13:01:27
0

在Android系统中,如果需要进行屏幕录制,系统会提示用户是否允许录制屏幕。如果需要去掉这个提示,可以通过代码来实现。具体的解决方法如下:

  1. 在AndroidManifest.xml文件中添加录制屏幕的权限:



  1. 创建一个MediaProjectionManager对象用于获取MediaProjection:
private MediaProjectionManager mMediaProjectionManager;
private MediaProjection mMediaProjection;
private int mScreenDensity;

mMediaProjectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE);
mMediaProjection = mMediaProjectionManager.getMediaProjection(resultCode, data);
mScreenDensity = getResources().getDisplayMetrics().densityDpi;
  1. 创建VirtualDisplay并开始录制:
private static final int DISPLAY_WIDTH = 720;
private static final int DISPLAY_HEIGHT = 1280;

private  VirtualDisplay mVirtualDisplay;
private  MediaRecorder mMediaRecorder;

mVirtualDisplay = mMediaProjection.createVirtualDisplay("ScreenCapture",
    DISPLAY_WIDTH, DISPLAY_HEIGHT, mScreenDensity,
    DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
    mMediaRecorder.getSurface(), null /*Callbacks*/, null /*Handler*/);

mMediaRecorder.start();

通过以上代码可以实现在Android系统中进行录屏功能,不再弹出提示窗口。

相关内容

热门资讯

透视规律!wepoker透视脚... 透视规律!wepoker透视脚本下载,WePoKer辅助器(透视)总结教程(有挂助手)-哔哩哔哩一、...
有玩家发现!wepoker智能... 有玩家发现!wepoker智能辅助插件,wpk透视是真的吗(透视)必备教程(有挂工具)-哔哩哔哩1、...
更值得关注的是!哈糖大菠萝怎么... 更值得关注的是!哈糖大菠萝怎么开挂,拱趴大菠萝万能挂(透视)必备教程(果真有挂)-哔哩哔哩1)哈糖大...
此事备受玩家关注!hhpoke... 此事备受玩家关注!hhpoker辅助挂是真的吗,拱趴大菠萝辅助方法(透视)揭幕教程(竟然有挂)-哔哩...
围绕透视问题!wepoker国... 围绕透视问题!wepoker国外版透视,wepoker怎么获得好牌(透视)揭幕教程(有挂实锤)-哔哩...
透视挂!wepokerplus... 透视挂!wepokerplus辅助,we-poker辅助(透视)教你教程(果真有挂)-哔哩哔哩;1、...
透视ai代打!newpoker... 透视ai代打!newpoker脚本,wepoker私人局透视插件(透视)辅助教程(发现有挂)-哔哩哔...
据文件显示!wepoker透视... 据文件显示!wepoker透视脚本免费使用视频,德州局透视脚本(透视)详细教程(有挂总结)-哔哩哔哩...
透视规律!智星菠萝有挂吗,we... 透视规律!智星菠萝有挂吗,wepoker有辅助插件吗(透视)详情教程(有挂秘籍)-哔哩哔哩1、点击下...
目前来看!wpk私人辅助,约局... 目前来看!wpk私人辅助,约局吧透视挂下载(透视)辅助教程(有挂详情)-哔哩哔哩小薇(辅助器软件下载...