5 service android repeat alarmmanager
我有totalTime = 1小时和intervalTime = 5分钟,都是毫秒,
我想在每个时间间隔重复我的GPS设置服务,在完成总时间之后,这个重复应该停止.
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
Intent intent1 = new Intent(C2DMReceiver.this, GPSSetting.class);
PendingIntent pendingIntent = PendingIntent.getService(
C2DMReceiver.this, 0, intent1, 0);
am.setRepeating(AlarmManager.RTC, System.currentTimeMillis(), intervalTime,
pendingIntent);
Run Code Online (Sandbox Code Playgroud)
那么如何才能阻止这种重复警报呢?
问候,Girish
创建与PendingIntent注册警报时相同的方法,并用于AlaramManager.cancel()取消警报。
| 归档时间: |
|
| 查看次数: |
11320 次 |
| 最近记录: |