Facebook,Evernote,Pocket - 所有应用程序都会自动在Android 6.0上获得此权限,即使它们的目标是23(targetSdkVersion=23).
关于新的Marshmallow权限模型有很多文档.其中一个SYSTEM_ALERT_WINDOW被"提升"为"高于危险"的权限级别,因此需要特殊的用户干预才能授予应用程序这些权限.如果应用程序有targetSdkVersion22或更低,app会自动获得此权限(如果在清单中请求).
但是,我注意到一些获得此权限的应用程序,无需将用户发送到设置特殊页面的Draw over other apps权限.我看到Facebook,Evernote,Pocket - 也许还有更多.
任何人都知道在没有用户通过的情况下如何授予应用程序此权限Settings -> Apps -> Draw over other apps?
谢谢
android android-permissions target-sdk system-alert-window android-6.0-marshmallow
我正在创建一个叠加层,它将覆盖屏幕上所有显示的视图.即使在rootViewController更改,推送或呈现的情况下,此叠加始终显示.
我的想法是
CustomWindow哪个是子类UIWindow.在更换默认之后window的UIApplication有CustomWindow,创建一个新的rootViewController为我的新窗口.CustomWindow,我有一个overlay(是UIView).Overlay浅灰色,带有阿尔法,每个事件overlay都会传递到下面的视图.CustomWindow添加一个新的子视图时,我都会把它overlay带到前面.它确保overlay在每种情况下都是最重要的.CustomWindow
@implementation CustomWindow
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
_overlay = [[UIView alloc] initWithFrame:self.bounds];
_overlay.userInteractionEnabled = NO;
_overlay.backgroundColor = [UIColor lightGrayColor];
_overlay.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self addSubview:_overlay];
}
return self;
}
- (void)didAddSubview:(UIView *)subview {
[super didAddSubview:subview];
[self bringSubviewToFront:_overlay];
} …Run Code Online (Sandbox Code Playgroud)