2011-03-18 217 views
0

我正在开发Android上的天气预报应用程序。 我已经集成了buzzbox调度程序,并且我已经写了一个任务,使用cron字符串“0 */3 * * 1,2,3,4,5,6,7”每3小时检查一次天气状况这里http://hub.buzzbox.com/android-sdk/quickstart使用BuzzBox sdk的Android通知类型

我有2种通知类型:“恶劣天气”与“气候警报”和我创建这样的消息:

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

我如何设置振动第一通知和第二种类型的声音? 另外,我只在设置活动中看到一个配置部分。我可以为每种类型的通知打开不同的配置设置吗?

回答

0

在代码中使用不同的配置设置,只需添加:

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" />