服务未在android中启动

时间:2014-04-23 13:01:56

标签: android service notifications alarm

我想点击按钮通知服务。我在android manifest中注册了服务,给出了空指针异常。

public void SetReminder(View v)
{
    // Get the date from our datepicker
    int day = s_day/*picker.getDayOfMonth()*/;
    int month = s_month/*picker.getMonth()*/;
    int year = s_year/*picker.getYear()*/;


    // Create a new calendar set to the date chosen
    // we set the time to midnight (i.e. the first minute of that day)
    Calendar c = Calendar.getInstance();
    c.set(year, month, day);
    c.set(Calendar.HOUR_OF_DAY, 8);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);

    // Ask our service to set an alarm for that date, this activity talks to the client that talks to the service
    scheduleClient.setAlarmForNotification(c);

    // Notify the user what they just did
    Toast.makeText(this, "Notification set for: "+ day +"/"+ (month+1) +"/"+ year, Toast.LENGTH_SHORT).show();
}


<service android:name="com.bnmcombines.service.ScheduleService" >
</service>
<service android:name="com.bnmcombines.service.NotifyService" >
</service>

0 个答案:

没有答案