Android notification types with BuzzBox sdk
I'm developing a weather alarm application on Android. I've integrated the buzzbox scheduler and I've written a task to check the weather condition every 3 hours using the cron string "0 */3 * * 1,2,3,4,5,6,7" as described here http://hub.buzzbox.com/android-sdk/quickstart
I have 2 notification types: "bad-weather" and "weather-alert" and I'm creating the messages like this:
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);
}
How can I set up vibration for the first notification a开发者_开发百科nd a sound for the second type? Also, I only see one configuration section in the settings activity. Can I open up a different configuration settings for each type of notification?
To use different configuration setting in code just add:
new NotificationMessage("weather-alert","Weather Alert!","Tomorrow: Severe Weather",weatherDetails,R.id.icon_weather_alert)
.setNotificationSettings(true, false, false)
where the parameters are
setNotificationSettings( doSound , doVibrate , doLed)
the Notification Settings include can include different section for each of your notification type if you declare them in the 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" />
精彩评论