Android跳转到应用程序通知的设置操作
来源:爱站网时间:2021-03-15编辑:网友分享
android开发中需要提示用户打开这个应用,要怎么操作?而程序员为了方便用户的实际操作,要怎么跳转呢?爱站技术频道小编今天就和大家分享的Android跳转到应用程序通知的设置操作,希望能为你带来帮助。
android开发中需要提示用户打开这个应用,要怎么操作?而程序员为了方便用户的实际操作,要怎么跳转呢?爱站技术频道小编今天就和大家分享的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
对于检测app是否开启通知,同样是针对4.4以上的系统才有效:
NotificationManagerCompat manager = NotificationManagerCompat.from(App.getInstance().getContext()); boolean isOpened = manager.areNotificationsEnabled();
4.4以下调用该方法并不会出错,只是全部返回true,默认开启状态
我们可以看到爱站技术频道小编介绍的Android跳转到应用程序通知的设置操作是比较全面的,而且随着.net的不断发展,大家都要不断的完善好各种功能,希望本文能够帮助到大家。
