2015-02-24 133 views
12

在Android 5.0上,通过Settings -> Sound & notification -> App notification -> Calendar (for example)有一个选项可直接转到应用程序的通知设置。
我也知道它是清单中的一个标志,如DEV.BYTES talk中所述。
如何实现,使用的是什么标志?如何将通知设置活动添加到系统设置

下面是更多的澄清截图:
enter image description here

+0

我本来期望看到的东西[应用程序的清单(https://android.googlesource.com/platform/packages/apps/Calendar/+/master /AndroidManifest.xml),但似乎没有可能。 – CommonsWare 2015-02-24 12:17:26

+1

@CommonsWare利用通知首选项的Google日历应用程序是Google在Play商店中的专有应用程序。 – adneal 2015-02-25 02:45:39

回答

22

你需要通过你的AndroidManifestIntent类别Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES添加到Activity你想推出。一个简单的例子是这样的:

<activity android:name="com.example.packagename.YourSettingsActivity" > 

     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.NOTIFICATION_PREFERENCES" /> 
     </intent-filter> 
    </activity> 

有关详细信息,请参阅设置应用和具体的NotificationAppListAppNotificationSettings片段。

结果

example

+2

谢谢你的回答,出于好奇,你是如何找到它的? – 2015-02-25 07:31:31

+3

@ Alex.F我查看了设置应用程序的源代码。 – adneal 2015-02-25 08:59:16

+0

请查看http://stackoverflow.com/questions/28790754/android-lollipop-app-notification-settings/37054087#37054087关于如何更深入地指出您的PreferenceActivity子类中的特定片段 – Gabriel 2016-05-05 15:10:33