[英]SYSTEM_ALERT_WINDOW option greyed out (not changeable)
I'm working on an App that is uses the SYSTEM_ALERT_WINDOW permission. 我正在使用使用SYSTEM_ALERT_WINDOW权限的应用程序。 I've added the permission to the Manifest.
我已将权限添加到清单中。
In my activity, I've added the following code to ask permission at runtime. 在我的活动中,我添加了以下代码以在运行时请求权限。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Intent myIntent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
startActivityForResult(myIntent, 5469);
}
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case 5469: {
Toast.makeText(this,"Permission Granted!",Toast.LENGTH_SHORT).show();
return;
}
}
}
But, as the "Draw over other Apps" setting page is opened, the 'switch button' to allow the permission is greyed out(not clickable). 但是,随着“在其他应用程序上绘制”设置页面打开,允许权限的“切换按钮”显示为灰色(不可点击)。
Given below is the screenshot : 下面给出的是屏幕截图:
Code for Manifest : 清单代码:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.graphics.unlockbrtest">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SettingsActivity"
android:label="Settings"
android:theme="@style/AppTheme.NoActionBar" />
<receiver
android:name=".UnlockReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<activity
android:name=".FloatingActivity"
android:theme="@android:style/Theme.Dialog" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
</application>
What am I doing wrong that the option is greyed out? 该选项显示为灰色,我在做什么错? Thanks in advance!
提前致谢!
将<uses-permission>
元素移动为<manifest>
的直接子元素,在<application>
元素之外。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.