Android 录屏相关,会弹出一个请求屏幕录制权限的对话框。

2020-10-23 15:31:32 +08:00
 youla

MediaProjectionManager.createScreenCaptureIntent();

我现在拥有 root 权限,我希望录制屏幕时不要弹出确认授权对话框。

我想知道这个权限的具体名称是什么。

Google 了很久,也木有找到。

6972 次点击
所在节点    Android
25 条回复
jnmsn8806
2020-10-23 15:59:48 +08:00
不懂你说的是什么意思。录屏软件需要 root 权限?
youla
2020-10-23 16:03:17 +08:00
@jnmsn8806 录屏会提示要授权啊,我希望不要授权,直接投影。
zapper
2020-10-23 16:06:59 +08:00
MediaProjectionManager.createScreenCaptureIntent() 方法说明:

Returns an Intent that must be passed to startActivityForResult() in order to start screen capture. The activity will prompt the user whether to allow screen capture. The result of this activity should be passed to getMediaProjection.

看起来不能取消这个授权,除非改了系统。
youla
2020-10-23 16:13:47 +08:00
@zapper 不知道能不能通过 root 能不能获取到对话框完成自动点击...继续 code,,,
Cielsky
2020-10-23 16:14:06 +08:00
有个想法,可以试试试试自动跳过类软件,一遇到询问自动点击
youla
2020-10-23 16:14:15 +08:00
@zapper code 到脑部坏死,发出来一句话都读不通。
youla
2020-10-23 16:15:50 +08:00
@Cielsky 有想过,现在看看能不能直接通过 root 调用到系统 api 之类的吧,坐标点击适配感觉麻烦。
jnmsn8806
2020-10-23 16:16:17 +08:00
@youla,还是不懂你说的啥意思。

安卓录屏软件,首次安装后打开需要相关的授权,下次使用就不需要授权了啊。难道你的软件每次都要授权?
youla
2020-10-23 16:18:04 +08:00
@jnmsn8806 是的,但是我不只有一个设备,我们可能有几千几万台这种设备出厂,每个授权一次就很不实际。
youla
2020-10-23 16:19:50 +08:00
@jnmsn8806 当然主要还是客户提的要求,不得不做
zapper
2020-10-23 16:30:12 +08:00
你可以试试执行 shell,用 pm 预先授权
youla
2020-10-23 16:32:18 +08:00
@zapper 之前就是这么想的,关键不知道权限名字,后面找到一个疑似权限,但是授权报错。
zapper
2020-10-23 16:46:29 +08:00
@youla 查到一个只能授予系统软件的权限"android.permission.MANAGE_MEDIA_PROJECTION"
不知道管不管用
LLaMA2
2020-10-23 20:17:48 +08:00
哦, 你是自己的程序是把,那就 screencap 命令啊!
LLaMA2
2020-10-23 20:19:49 +08:00
2|shell@msm8909:/ $ screenrecord --help
Usage: screenrecord [options] <filename>

Android screenrecord v1.2. Records the device's display to a .mp4 file.

Options:
--size WIDTHxHEIGHT
Set the video size, e.g. "1280x720". Default is the device's main
display resolution (if supported), 1280x720 if not. For best results,
use a size supported by the AVC encoder.
--bit-rate RATE
Set the video bit rate, in bits per second. Value may be specified as
bits or megabits, e.g. '4000000' is equivalent to '4M'. Default 4Mbps.
--bugreport
Add additional information, such as a timestamp overlay, that is helpful
in videos captured to illustrate bugs.
--time-limit TIME
Set the maximum recording time, in seconds. Default / maximum is 180.
--verbose
Display interesting information on stdout.
--help
Show this message.

Recording continues until Ctrl-C is hit or the time limit is reached
youla
2020-10-23 20:23:03 +08:00
@ye4tar 要用我上面的那个方法实现,我用的是别人封装好的,功能都做完了。
thetbw
2020-10-23 20:26:59 +08:00
不用这个 api 试试,以前安卓还没这个 api 的时候,有些 app 就可以录屏了,不过必须 root,你可以搜一下,类似安卓 4.4 是怎么实现录屏的。还有个软件叫 scrcpy,开源的,利用 adb 投屏的,你可以看看它用了哪些接口
youla
2020-10-23 20:28:45 +08:00
@thetbw 因为公司负责人以为做这个很难,请别人做的,所以必须要用别人的 jar 包,不然公司会觉得亏钱了。
youla
2020-10-23 20:29:40 +08:00
@thetbw 我还没到公司之前他们就在做,而且都是这个功能,我接手的时候真的是一言难尽,现在其实都还很多 bug,有一部分还是我利用 root 解决的。
mxalbert1996
2020-10-24 10:27:37 +08:00
这种问题一般去查系统源代码比较快

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/717876

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX