0

I'm creating an app that will do the following:

If a mail comes in with a messageword. It needs to start to locate the phone by GPS functionality. after that it must show the result to the user.

I already have it working with using a broadcastreceiver for fetch the message. After that is starts an Activity. If don the userinterface is updated.

I have here two problems:

1) if the screen rotates all variables are set to zero... well can solve that with saving variables at onPause() and read those values at onResume()

2) if the user use the backbutton... the thread is cancelled.

Actually I want that the user can't cancel the GPS-action.

Is it a good idea to use an Intentservice for this?!

-message comes in

-BroadcastReceiver fetch the message and start the intentService

-if the processing is done... I can start an activity with the results (and the service is closed automaticly after the processing is done?!

Is there maybe a better way to attack the problem?

4

1 に答える 1

1

IntentServiceバックグラウンドでの長時間実行操作には、確かに を使用できますし、使用する必要があります。しかし、ユーザーがあなたのアクティビティを取りやめた場合、彼らは何らかの理由でこれを行った可能性が高く、もはや気にしない結果を含むアクティビティをポップアップ表示することは、あまり良い戦略ではない可能性があります。代わりに結果をキャッシュし、次にユーザーがアクティビティを開いたときに表示することができます。

于 2012-06-04T08:54:22.530 に答える