Android 安卓重复报警还是服务?

Android 安卓重复报警还是服务?,android,service,notifications,alarm,Android,Service,Notifications,Alarm,我创建了一个应用程序,它根据地理坐标计算一天中的特定时间集。它会在这些时间发出通知。 我使用重复报警来通知每日(尽管每天的计时都会改变,因此不准确)。 但它不会在3天后通知我(我没有观察到确切的天数),除非重置。为什么会这样? 现在我决定使用这项服务,它将每天设置通知,因此是准确的。如何编写服务并调用它 public void alarmNoon(long diff) { Intent intent = new Intent(this, PNoon.class); Pen

我创建了一个应用程序,它根据地理坐标计算一天中的特定时间集。它会在这些时间发出通知。 我使用重复报警来通知每日(尽管每天的计时都会改变,因此不准确)。 但它不会在3天后通知我(我没有观察到确切的天数),除非重置。为什么会这样? 现在我决定使用这项服务,它将每天设置通知,因此是准确的。如何编写服务并调用它

public void alarmNoon(long diff) {
      Intent intent = new Intent(this, PNoon.class);
      PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0,
            intent, PendingIntent.FLAG_CANCEL_CURRENT);
      if (checkadan(1)==true){
          if (diff>=0){
          am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+diff,
            (1000*60*60*24), pendingIntent);}else{
          am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+diff+(1000*60*60*24), (1000*60*60*24), pendingIntent);
            }}else{
                am.cancel(pendingIntent);
            }
     }
diff是正午和当前时间的时差

public class PNoon extends BroadcastReceiver {
Dialog db;
@Override
public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub
    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);
    Notification notification = new Notification( R.drawable.icon, "Time", System.currentTimeMillis());
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, 0);
    notification.setLatestEventInfo(context,  "Time", "Its Noon", contentIntent);      
    notification.flags=Notification.FLAG_AUTO_CANCEL;
    notification.sound=Uri.parse("android.resource://net.ttct.time/"+R.raw.NoonAnnouncement);
    mNotificationManager.notify(1, notification);

}
}
此外,一旦将通知栏拖开,声音就会停止,只有当在通知栏中触摸到项目时,声音才会停止

<receiver  android:process=":remote" android:name="PNoon"></receiver>


并在manifest.xml中注册您的广播,您阅读了吗?发布您的代码(您如何安排警报),不要忘记声明广播接收者的清单。我希望情况清楚。警报每天在黎明、中午和黄昏设置通知。我应该实施本地服务还是远程messenger服务?区别是什么?
       PendingIntent.FLAG_CANCEL_CURRENT change it as intent.FLAG_NEW_TASK