有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

2007窗口类型的java Android权限被拒绝

我正在我的项目中使用这个库:https://github.com/recruit-lifestyle/FloatingView

我得到了这个错误: 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);

共 (1) 个答案

  1. # 1 楼答案

    此库使用SYSTEM_ALERT_WINDOW权限

    从android M开始,每个请求SYSTEM_ALERT_WINDOW权限并通过Play Store安装(需要6.0.5或更高版本)的应用程序将自动获得该应用程序的权限

    如果不是从play store安装应用程序,则不会自动授予该权限。您必须在运行时手动请求此权限,就像其他危险的权限是从Android M及更高版本处理的一样