2017-08-10 117 views
0

我在我的项目中使用这个库:https://github.com/recruit-lifestyle/FloatingView的Android权限被拒绝窗式2007

,我得到这个错误: Click here for picture of error

这个库不工作的棉花糖和牛轧糖。

代码:

final LayoutInflater inflater = LayoutInflater.from(bCon); 
    final ImageView iconView = (ImageView)  inflater.inflate(R.layout.widget_chathead, null, false); 

final DisplayMetrics metrics = new DisplayMetrics(); 
     final WindowManager windowManager = (WindowManager)bCon.getSystemService(Context.WINDOW_SERVICE); 
     windowManager.getDefaultDisplay().getMetrics(metrics); 
     mFloatingViewManager = new FloatingViewManager(bCon, this); 
     mFloatingViewManager.setFixedTrashIconImage(R.drawable.ic_trash_fixed); 
     mFloatingViewManager.setActionTrashIconImage(R.drawable.ic_trash_action); 
     final FloatingViewManager.Options options = new FloatingViewManager.Options(); 
     options.overMargin = (int) (16 * metrics.density); 
     mFloatingViewManager.addViewToWindow(iconView, options); 
+0

@EJoshuaS无法添加窗口android.view.ViewRootlm[email protected] - 针对窗口类型2007的权限denides –

回答

1

此库使用SYSTEM_ALERT_WINDOW许可

从版本的Android M起每个应用程序,请求SYSTEM_ALERT_WINDOW权限,并通过Play商店(版本6.0.5或更高版本是必需的),将拥有为应用程序自动授予的权限。

如果应用程序未从Play商店安装,则不会自动授予该权限。您必须在运行时手动请求此权限,就像从Android M及以上版本处理其他危险权限一样。

+0

如何在Google Play上获取系统警报窗口应用程序?我没有找到 –

+0

它不是一个应用程序。这意味着如果您的应用程序使用该权限,则将自动从游戏商店下载该权限。但是,如果您从别处安装,则必须通过代码手动请求权限。 –

+0

好的,那我怎样才能在Play商店中获得系统警报窗口?因为没有安装 –