2

目前我们正计划使用alarmmanager服务来做到这一点..检查下面的代码

有更好的方法吗?

Intent intent1= new Intent(ScheduleManagement.this,ScheduleManagementService.class); Intent intent2= new Intent(ScheduleManagement.this,ScheduleManagementService.class); Intent intent3= new Intent(ScheduleManagement.this,ScheduleManagementService.class);

    intent1.putExtra("msg", "Good morning Sweety ");

   intent1.putExtra("msg", "Good afternoon  ");
  intent1.putExtra("msg", "Good night ");



     /*pendingIntent will fire based on the time
     * request code also differ...
     * same pending intent object...
     * same service but intent properties are different.
     *  */

    Date dt=new Date();

    Log.d("sri", "sriii"+dt.getTime());

    long current_time=calendar.getTimeInMillis();
    pendingIntent =PendingIntent.getService(ScheduleManagement.this,1, intent1,3);
    alarmManager.set(AlarmManager.RTC_WAKEUP, current_time+1000000, pendingIntent);

    /*pendingIntent =PendingIntent.getService(ScheduleManagement.this,2, intent2,3);
    alarmManager.set(AlarmManager.RTC_WAKEUP, current_time +2000000, pendingIntent);*/

    pendingIntent =PendingIntent.getService(ScheduleManagement.this,3, intent3,3);
    alarmManager.set(AlarmManager.RTC_WAKEUP, current_time +3000000, pendingIntent);
4

0 回答 0