我正在Android上开发一个天气警报应用程序。我已经集成了buzzbox调度器,并且我已经编写了一个任务,使用cron字符串"0 */3 ** 1,2,3,4,5,6,7“每3小时检查一次天气状况,就像这里描述的http://hub.buzzbox.com/android-sdk/quickstart
我有两种通知类型:“坏天气”和“天气警报”,我创建的消息如下:
if (ALERT == type) {
notification = new NotificationMessage("weather-alert","Weather Alert!","Tomorrow: Severe Weather",weatherDetails,R.id.icon_weather_alert);
} else {
notification = new NotificationMessage("bad-weather","Bad Weather","Tomorrow: Bad Weather",weatherDetails,R.id.icon_weather_bad);
}如何设置第一个通知的振动和第二个类型的声音?此外,我在设置活动中只看到一个配置部分。我可以为每种类型的通知打开不同的配置设置吗?
发布于 2011-03-19 08:14:00
要在代码中使用不同的配置设置,只需添加:
new NotificationMessage("weather-alert","Weather Alert!","Tomorrow: Severe Weather",weatherDetails,R.id.icon_weather_alert)
.setNotificationSettings(true, false, false)其中的参数是
setNotificationSettings( doSound , doVibrate , doLed)如果在manifest.xml中声明了每种通知类型,则包含的通知设置可以包含不同的部分
<meta-data
android:name="SchedulerPreferenceActivity.notificationTypes"
android:value="bad-weather,weather-alert" />
<meta-data
android:name="SchedulerPreferenceActivity.notificationTypesLabels"
android:value="Bad Weather,Weather Alert" />
<meta-data
android:name="SchedulerPreferenceActivity.notificationTypes.defaultSettings.bad-weather"
android:value="statusBar=enabled,vibrate=disabled,led=disabled,sound=disabled" />
<meta-data
android:name="SchedulerPreferenceActivity.notificationTypes.defaultSettings.weather-alert"
android:value="statusBar=enabled,vibrate=disabled,led=disabled,sound=enabled" />https://stackoverflow.com/questions/5346783
复制相似问题