当前位置: 首页 > wzjs >正文

公司门户网站建设公司网络服务器图片

公司门户网站建设公司,网络服务器图片,网站快速搭建平台,嘚嘚笔记 wordpress主推Android开发检查是否开启通知栏权限 检查通知权限很场景,几乎每个app都有。 顺便提供跳到设置里面开启通知栏 一、查询是否有通知栏权限: RequiresApi(api Build.VERSION_CODES.KITKAT)public static boolean isNotificationEnabled(Context context…
Android开发检查是否开启通知栏权限

检查通知权限很场景,几乎每个app都有。 顺便提供跳到设置里面开启通知栏

一、查询是否有通知栏权限:

@RequiresApi(api = Build.VERSION_CODES.KITKAT)public static boolean isNotificationEnabled(Context context) {if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {//8.0手机以上if (((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).getImportance() == NotificationManager.IMPORTANCE_NONE) {return false;}}String CHECK_OP_NO_THROW = "checkOpNoThrow";String OP_POST_NOTIFICATION = "OP_POST_NOTIFICATION";AppOpsManager mAppOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);ApplicationInfo appInfo = context.getApplicationInfo();String pkg = context.getApplicationContext().getPackageName();int uid = appInfo.uid;Class appOpsClass = null;/* Context.APP_OPS_MANAGER */try {appOpsClass = Class.forName(AppOpsManager.class.getName());Method checkOpNoThrowMethod = appOpsClass.getMethod(CHECK_OP_NO_THROW, Integer.TYPE, Integer.TYPE,String.class);Field opPostNotificationValue = appOpsClass.getDeclaredField(OP_POST_NOTIFICATION);int value = (Integer) opPostNotificationValue.get(Integer.class);return ((Integer) checkOpNoThrowMethod.invoke(mAppOps, value, uid, pkg) == AppOpsManager.MODE_ALLOWED);} catch (Exception e) {e.printStackTrace();}return false;}

二、跳到设置里面开启通知

public static void startAppNotifySetting(Context mContext) {try {String packageName = mContext.getPackageName();int uid = mContext.getApplicationInfo().uid;Intent intent = new Intent();if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){intent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS);intent.putExtra(Settings.EXTRA_APP_PACKAGE, packageName);intent.putExtra(Settings.EXTRA_CHANNEL_ID, uid);} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");intent.putExtra("app_package", packageName);intent.putExtra("app_uid", uid);} else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT){intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);intent.addCategory(Intent.CATEGORY_DEFAULT);intent.setData(Uri.fromParts("package", packageName, null));} else {intent.setAction(Settings.ACTION_SETTINGS);}mContext.startActivity(intent);} catch (Exception e){e.printStackTrace();Intent intent = new Intent();intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");intent.setData(Uri.fromParts("package", mContext.getPackageName(), null));mContext.startActivity(intent);}}
http://www.dtcms.com/wzjs/203298.html

相关文章:

  • 比较好的网页网站设计网站权重怎么看
  • 怎么查网站是哪家公司做的seo排名优化资源
  • 对网站开发实训的建议南京seo网站优化
  • 设计网站物理结构怎么做百度站长快速收录
  • 做app网站需要什么软文营销的作用有哪些
  • 哪个做企业网站百度图片识别搜索引擎
  • 免费制作单页的网站百度竞价排名怎么靠前
  • 专业加速器产业园广州搜索排名优化
  • 武汉外贸网站建设公司排名灰色产业推广引流渠道
  • 建站优化是什么大专网络营销专业好不好
  • 如何在网站做qq群链接杭州百度快照优化排名
  • 做带v头像的网站免费外链发布平台
  • 网站开发使用的软件苏州网站关键词优化推广
  • 郑州做网站的专业公司有哪些优化关键词的方法有哪些
  • 互联网官网北京seo服务商
  • 做网站的客户资料交换qq群网站关键词优化公司
  • 通州网站建设公司seo外包公司哪家好
  • 做外贸建网站多少钱搜狗收录提交入口
  • 做网站端口映射油烟机seo关键词
  • 网站开发要多长时间哪些平台可以打小广告
  • 微信网站开发技术磁力神器
  • 英文商城网站建设免费个人网站申请
  • 苏州建网站成都网站建设方案服务
  • 网站域名被注册seo评测论坛
  • 学历提升咨询seo网站外链工具
  • 云主机网站模板seo图片优化
  • 建一个公司网站要多久怎么免费建立网站
  • 旅游电商网站有哪些长沙官网优化公司
  • 萧山网站建设争锋网络怎么弄一个网站平台
  • 网站建设项目功能需求分析报告老铁seo外链工具