2

I'm trying to search for a user's location, my problem is that I want to limit the time search by time. That is, if a good enough location was not found after ten seconds or so, return the best location found until that time.

I have an asynctask that activates a location listener. I'm trying to limit the time with android.os.Process.getElapsedCpuTime() but it only works when I get a location from my location listener that has arrived after the time set.

What I want to do is to keep running the time passed, regaredless of the location listener. How can I do so?

Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
oferiko
  • 1,927
  • 2
  • 16
  • 17
  • look at this post http://stackoverflow.com/questions/7882739/android-setting-a-timeout-for-an-asynctask – yehudahs Oct 08 '13 at 16:41

1 Answers1

0

Why cant u run a Timer (Java.util.Timer) where you can create a TimerTask. Start both AsyncTask and Timer at a time by scheduling the interval of 10 seconds. then after 10 seconds just check the status of the asynctask. if it is still in RUNNING or PENDING state then cancel the asynctask. I think this will helpful to you.

Pavandroid
  • 1,586
  • 2
  • 15
  • 30