红米A1+如何开启‘Display over other apps’权限及Manifest代码添加方法
红米A1+开启“Display over other apps”权限及Manifest代码添加指南
一、开启悬浮窗权限(Display over other apps)的步骤
- 打开手机设置
- 进入应用设置(部分机型显示为“应用管理”)
- 在应用列表中找到目标应用,进入其应用信息页面
- 选择权限管理
- 在权限列表里找到悬浮窗(对应英文的Display over other apps),点击后选择允许
二、向AndroidManifest.xml添加相关代码的方法
注意:普通第三方应用无法通过代码绕过该权限,只有系统签名的应用或满足特定系统要求的应用才能生效。
- 打开项目中的
AndroidManifest.xml文件 - 在根标签
<manifest>内添加权限声明(如果尚未添加):
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
- 若为系统应用,可在
<application>标签内添加属性以默认获取权限:
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:permission="android.permission.SYSTEM_ALERT_WINDOW" <!-- 添加这一行 --> android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.MyApp"> <!-- 其他组件声明 --> </application>
提醒:非系统应用即使添加上述代码,仍需用户手动开启悬浮窗权限,代码仅对系统签名应用有效。
内容的提问来源于stack exchange,提问作者Lexzee
相关产品推荐
相关产品推荐

