私のバックグラウンドサービスは、デバイスのジオデータをAPIに送信させます。AlarmManagerがすぐに起動する
private static long LOCATION_INTERVAL = 1800000;
位置サービスと、AlarmManager
の間隔とします。
私はその後、この
Intent i = new Intent(this, typeof(LocationService));
PendingIntent pending = PendingIntent.GetService(this, 1, i,
PendingIntentFlags.CancelCurrent);
AlarmManager alarm = (AlarmManager)GetSystemService(AlarmService);
alarm.SetExact(AlarmType.RtcWakeup, 30000, pending);
ようMainActivity
で火災最初のアラーム、サービス自体に、私はすべての時間、この
Intent intent = new Intent(this, typeof(LocationService));
PendingIntent pending = PendingIntent.GetService(this, 100, intent,
PendingIntentFlags.CancelCurrent);
AlarmManager alarm = (AlarmManager)GetSystemService(AlarmService);
alarm.SetExact(AlarmType.RtcWakeup,
LOCATION_INTERVAL, pending);
問題のようにアラームトリガーを再:サービスを取得しますあまりにも早すぎる(+/-毎分!)。
質問:アラームマネージャをLOCATION_INTERVAL
に固定するにはどうすればよいですか?
...それは全体の日付を(だけではなく間隔)を表す数値です... 2番目のパラメータはミリ秒単位の日付であることに注意してください? – Shaishav
@ Shaishavこれは 'return StartCommandResult.Sticky; 'を返します。 – Saphire
NON_STICKYで試してみてください。 xamarin同等物が何であれ。 – Shaishav