サーバーの更新をポーリングするためIntentService
に a への繰り返し呼び出しを開始するために、次のようなものがあります。BroadcastReceiver
AlarmManager pollManager;
Intent pollIntent;
PendingIntent pollPendingIntent;
...
pollIntent = new Intent(getActivity(), ActionUpdateReceiver.class);
pollIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
pollIntent.putExtra(RECEIVER, resultReceiver);
pollIntent.putExtra(USER, accountId);
// This is the crux of my question
pollIntent.putExtra(SOMETHING_THAT_UPDATES, updatingThing);
pollPendingIntent = PendingIntent.getBroadcast(getActivity(), ACTION_REQUEST,
pollIntent, PendingIntent.FLAG_CANCEL_CURRENT);
pollManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(),
POLL_INTERVAL, pollPendingIntent);
サーバーをポーリングし、ResultReceiver
サーバーの更新を取得するために を使用するという点では、上記のアプローチはうまく機能します。ただし、更新クエリを変更するには、ポーリング サービスにフィードバックを提供する必要があります。
ポーリング サービスにフィードバックを提供するにはどうすればよいですか? 更新されたクエリが必要な場合、現在のアラームをキャンセルしてインテントを再度セットアップするだけでよいですか? キャンセルするよりも良い方法はありますか?