关于MediaProjection的问题

本文探讨了使用MediaProjection创建虚拟显示的过程,并针对如何仅捕获应用内部视图而非整个屏幕内容进行了讨论。同时,文章还分析了不同标志位的作用及其在实际应用中的表现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

写了一个app来投影,用了MediaProjection的createVirtualDisplay(String name, int width, int height, int dpi, int flags, Surface surface, VirtualDisplay.Callback callback, Handler handler),文档说明就一句话: Creates a VirtualDisplay to capture the contents of the screen. 这个意思应该就是数据源是screen吧,现在我只想要抓取我APP内部的视图,该怎么做呢?

现在大部分android手机取消物理按键,那三个键都显示在屏幕上了,我不想要投影这三个键,该怎么设置啊?

还有这个flag,我不太看得懂了,下面几个flag我都一一试过了,投影过去的东西没有任何差别。
VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR
Virtual display flag: Allows content to be mirrored on private displays when no content is being shown.
int VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY
Virtual display flag: Only show this display's own content; do not mirror the content of another display.
int VIRTUAL_DISPLAY_FLAG_PRESENTATION
Virtual display flag: Create a presentation display.
int VIRTUAL_DISPLAY_FLAG_PUBLIC
Virtual display flag: Create a public display.
int VIRTUAL_DISPLAY_FLAG_SECURE
Virtual display flag: Create a secure display.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值