新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
怎么從android中跳轉(zhuǎn)到應(yīng)用通知設(shè)置界面-創(chuàng)新互聯(lián)
這篇文章主要介紹了怎么從android中跳轉(zhuǎn)到應(yīng)用通知設(shè)置界面,此處通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考價值,需要的朋友可以參考下:
Android是一種基于Linux內(nèi)核的自由及開放源代碼的操作系統(tǒng),主要使用于移動設(shè)備,如智能手機(jī)和平板電腦,由美國Google公司和開放手機(jī)聯(lián)盟領(lǐng)導(dǎo)及開發(fā)。
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)用詳情頁面的代碼如下:
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以上的系統(tǒng)才有效:
NotificationManagerCompat manager = NotificationManagerCompat.from(App.getInstance().getContext()); boolean isOpened = manager.areNotificationsEnabled();
4.4以下調(diào)用該方法并不會出錯,只是全部返回true,默認(rèn)開啟狀態(tài)
到此這篇關(guān)于怎么從android中跳轉(zhuǎn)到應(yīng)用通知設(shè)置界面的文章就介紹到這了,更多相關(guān)怎么從android中跳轉(zhuǎn)到應(yīng)用通知設(shè)置界面的內(nèi)容請搜索創(chuàng)新互聯(lián)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持創(chuàng)新互聯(lián)!
文章題目:怎么從android中跳轉(zhuǎn)到應(yīng)用通知設(shè)置界面-創(chuàng)新互聯(lián)
文章來源:http://www.dlmjj.cn/article/jchep.html