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?

Ronak Mehta
  • 5,971
  • 5
  • 42
  • 69
user1404924
  • 95
  • 1
  • 2
  • 11

1 Answers1

1

You certainly can and should use an IntentService for long running operations in the background. However, if the user backed out of your activity, they most probably did this for a reason, and popping up an activity with results they might not care about anymore, might not be such a good strategy. You could cache the result instead, and show it next time the user opens your activity.

Nikolay Elenkov
  • 52,576
  • 10
  • 84
  • 84