欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

android 跳轉(zhuǎn)到應(yīng)用通知設(shè)置界面的示例

 更新時(shí)間:2017年10月17日 09:06:51   作者:??岬挠? 
本篇文章主要介紹了android 跳轉(zhuǎn)到應(yīng)用通知設(shè)置界面的示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

4.4以下并沒(méi)有提過(guò)從app跳轉(zhuǎn)到應(yīng)用通知設(shè)置頁(yè)面的Action,可考慮跳轉(zhuǎn)到應(yīng)用詳情頁(yè)面,下面是直接跳轉(zhuǎn)到應(yīng)用通知設(shè)置的代碼:

 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);
        }

跳轉(zhuǎn)到應(yīng)用詳情頁(yè)面的代碼如下:

 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);

對(duì)于檢測(cè)app是否開啟通知,同樣是針對(duì)4.4以上的系統(tǒng)才有效:

NotificationManagerCompat manager = NotificationManagerCompat.from(App.getInstance().getContext());
boolean isOpened = manager.areNotificationsEnabled();

4.4以下調(diào)用該方法并不會(huì)出錯(cuò),只是全部返回true,默認(rèn)開啟狀態(tài)

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論