0

特定の時間間隔 (約 2 ~ 5 分) 後にサービスからデータ ポーリング (通知) を実行したいと考えています。サーバーからデータを取得するサービスを作成しました。したがって、以下のオプションからパフォーマンスの観点から最善の方法は何ですか.

  1. アラームマネージャを使用してポーリングを行うたびにサービスを開始する
  2. または、Alarm manager を使用して Boot Completed でサービスを開始し、特定の時間間隔ごとにタスクを実行する別の Alarm Manager をサービス内に保持します。

皆さんありがとう..

4

1 に答える 1

1

I think the first option is better. Start IntentService with alarm manager. IntentService will receive the Intents, launch a worker thread, and stop the service as appropriate.

See: http://developer.android.com/reference/android/app/IntentService.html

于 2012-04-06T11:03:59.853 に答える