![]() | Location |
|
31 Dec 2010, 21:50
Dave Murray (28 posts) |
Criteria criteria = new Criteria(); sets no preferences and always selects network as best. I’ve tried all sorts of things that all give errors to set a preference for fine so it will use the GPS. How do you do it? The Android Developers reference gives not example that I can find. |
|
31 Dec 2010, 22:18
Dave Murray (28 posts) |
I got it to accept:
Criteria ACCURACY_FINE = new Criteria();
best = mgr.getBestProvider(ACCURACY_FINE, true);
log(”\nBest provider is: ” + best); I must seriously not understand this lesson. |
|
03 Jan 2011, 01:57
Ed Burnette (1316 posts) |
Here’s an example that should get you the GPS location. Note it make take a minute or two for the GPS to lock on.
If this doesn’t do what you want, you might have to use the getProviders() or getAllProviders() method and do extra checks in your code to find the right provider according to your custom criteria. For complex use cases you might find this helpful: |
|
03 Jan 2011, 21:35
Dave Murray (28 posts) |
Thank you. I haven’t figured out how to get past the errors yet, but I’m working on it.
2 Errors: I’m not a Java programmer so I must learn both Android and Java unfortunately. |
|
03 Jan 2011, 22:46
Ed Burnette (1316 posts) |
Try this: |
|
04 Jan 2011, 02:39
Dave Murray (28 posts) |
Very cool! Thank you. Started with last known report. If GPS off: best=network, if GPS on: best=GPS updated on changes as accuracy increased over time and degraded as I walked under a roof. Reported bearing when I walked. That’s what I hoped to see. |
|
04 Jan 2011, 16:40
Ed Burnette (1316 posts) |
Great. By the way this post talks about resources for beginning Java programmers: And if you prefer C over Java, check out the Android NDK (Native Development Kit). |
|
05 Jan 2011, 12:56
Dave Murray (28 posts) |
Thanks again! |
|
06 Jan 2011, 15:33
Ed Burnette (1316 posts) |
No problem. |
| You must be logged in to comment |

