大佬教程收集整理的这篇文章主要介绍了android 跳转到应用通知设置界面的示例,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
4.4以下并没有提过从app跳转到应用通知设置页面的Action,可考虑跳转到应用详情页面,下面是直接跳转到应用通知设置的代码:
if (android.os.build.VERSION.SDK_INT >= Build.VERSION_CODEs.LOLLIPOp) { Intent intent = new Intent(); intent.setAction("android.setTings.APP_NOTIFICATION_SETTinGS"); intent.putExtra("app_package",getActivity().getPackagename()); intent.putExtra("app_uid",getActivity().getApplicationInfo().uid); startActivity(intent); } else if (android.os.build.VERSION.SDK_INT == Build.VERSION_CODEs.KITKAT) { Intent intent = new Intent(); intent.setAction(SetTings.ACTION_APPLICATION_DETAILS_SETTinGS); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setData(Uri.parse("package:" + getActivity().getPackagename())); startActivity(intent); }
Intent localIntent = new Intent(); localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (Build.VERSION.SDK_INT >= 9) { localIntent.setAction("android.setTings.APPLICATION_DETAILS_SETTinGS"); localIntent.setData(Uri.fromParts("package",getActivity().getPackagename(),null)); } else if (Build.VERSION.SDK_INT <= 8) { localIntent.setAction(Intent.ACTION_VIEW); localIntent.setClassName("com.android.setTings","com.android.setTings.InstalledAppDetails"); localIntent.putExtra("com.android.setTings.ApplicationPkgName",getActivity().getPackagename()); } startActivity(localIntent);
对于检测app是否开启通知,同样是针对4.4以上的系统才有效:
notificationmanagerCompat manager = notificationmanagerCompat.from(App.geTinstance().getContext()); Boolean isOpened = manager.areNotificationsEnabled();
4.4以下调用该方法并不会出错,只是全部返回true,默认开启状态
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程小技巧。
以上是大佬教程为你收集整理的android 跳转到应用通知设置界面的示例全部内容,希望文章能够帮你解决android 跳转到应用通知设置界面的示例所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。