tags:

views:

82

answers:

1

For example, I am inside a building and i want to get my location with the accuracy of 0.75 (Criteria.ACCURACY_FINE) and this will use the gps if my gps is on. Since I am inside a building, gps won't work.

How can I determine if it is really impossible to get a gps fix location?

Is onLocationChanged(Location arg0) will be called even though no gps fix location was received when using LocationListener?

Is it possible to use a timeout in requesting gps location so that I can shift to network as the location provider if i can't get any location?

+1  A: 

I see three basic possibilities:

  1. Setup a LocationListener, and then determine it based upon calls to onStatusChanged. My concern here is that I'm not sure how well android is able to determine the difference between OUT_OF_SERVICE and TEMPORARILY_UNAVAILABLE. I would hope that its based upon signal strength, but its probably something to test.
  2. Simply listen to both. If you haven't heard from the (more accurate) gps provider in a certain period of time, then switch to the less reliable approaches. This may consume more power due to the requirement to monitor multiple location sources simultaneously, but is probably the most reliable method otherwise.
  3. Some hybrid of 1 and 2 above (gps, but switch to local if no results for a while)... this might be the most efficient, but more difficult to implement.
jsight
Using the number 2 suggestion, can you suggest on how I can implement a "timer" so that given a duration, if I haven't heard from gps provider, I can switch to network provider.
M.A. Cape
Using your suggestion number 2 works.
M.A. Cape