最近做一个用户开启app通知的引导的功能,需要知道用户是否开启通知,如果没开启则跳转到通知界面
//判断推送通知是否开启
public static boolean isNotifyEnabled()
{
NotificationManagerCompat manager = NotificationManagerCompat.from(Cocos2dxHelper.getActivity().getApplicati onContext());
boolean isOpened = manager.areNotificationsEnabled();
return isOpened;
}
//跳转到开启推送通知
public static void openNotifyEnabled() {
Intent localIntent = new Intent();
try {
//直接跳转到应用详情设置的代码:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
{
//8.0及以上
//localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//localIntent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
//localIntent.setData(Uri.fromParts("package", instance.activity.getPackageName(), null));
//2 直接到通知界面