Android 系统升级后的坑

1、Android 8系统以上,需要单独处理悬浮窗口

      //大于8.0,popWindow的type改为 TYPE_APPLICATION_OVERLAY

      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

          mParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;

      } else {

          mParams.type = WindowManager.LayoutParams.TYPE_PHONE;

      }

2、android 7.0系统解决拍照的问题

      // android 7.0系统解决拍照的问题,在Application  onCreate方法中添加

      StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();

      StrictMode.setVmPolicy(builder.build());

      builder.detectFileUriExposure();

 

3、startForegroundService 启动服务的方法失效 (还未找到解决方案)

      if (Build.VERSION.SDK_INT >= 26) {

          context.startForegroundService(intent);

      } else {

          context.startService(intent);

      }

4、解决Android 8.0及以上系统接收不到广播的问题

      if (Build.VERSION.SDK_INT >= 26) {

         ComponentName componentName = new ComponentName(RongXinApplicationContext.getContext(),                       "com.yuntongxun.pluginexample.service.FilterMessageReceiver");//参数1-包名 参数2-广播接收者所在的路径名                                 intent.setComponent(componentName);

     }

你可能感兴趣的:(Android 系统升级后的坑)