安卓重复报警呼叫服务,有时报警停止重复


this is how i am starting a repeating service.
  Intent intent2 = new Intent(Main_page.this, SyncService.class);
  final AlarmManager alarm2 = (AlarmManager) 
  Main_page.this.getSystemService(Context.ALARM_SERVICE);
    PendingIntent pintent2 = PendingIntent.getService(Main_page.this, 0,  intent2, 0);
     alarm2.setRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime(), 2 * 60000, pintent2);

警报是否有可能停止重复。

您可以取消类似以下内容的意图:

Intent intent = new Intent(context, AlarmService.class);
PendingIntent pIntent = PendingIntent.getService(context, model.id, intent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarmManager.cancel(pIntent);

相关内容

  • 没有找到相关文章

最新更新