How to get the Android GPS
In fact, this is a pseudo-proposition, because I am not to say that the Android GPS access implementation, or the bottom-level implementation, but I directly use the Baidu map of the SDK, in which the direct access to GPS information, previously have done this function, today will be directly introduced to the demo to benefit everyone.
First step: Get the SDK
Baidu Map of the developer on the Internet can be downloaded directly to the thread of the demo, of course, the function is relatively complete, the basic solution requires a variety of map functions. Http://developer.baidu.com/map/index.php?title=androidsdk
Step two, get the key
Refer to official website
Step three, use the map
The use of Baidu map last year when the key is written or in the function, and now has been placed in the Androidmanifest.xml file, a service is configured in this file, a meta data is OK, configuration is relatively simple; add the C used in the Libs + + library file, and Baidu developed a jar package. These configurations make it possible to get GPS data directly.
Note: Getting GPS data is more than once, or it takes time to get it, so you have to start a new thread and keep getting it until you get GPS information.
In my demo I wrote a new class to better encapsulate the use of Baidu Map class, of course, I think the code is more intuitive, no excessive consideration of performance problems, we can directly refer to the demo Baidu.
New Thread (Newrunnable () { @Override public void Run () { //TODO auto-generated method stubs for (int i = 0; I < 10; i++) { try { thread.sleep ($); } catch (Interruptedexception e) { //TODO auto-generated catch block e.printstacktrace (); } System.out.println ("oncreat1" + "\ n" + "Longitude:" +loc.getjingdu () + "\ n" + "Latitude:" +loc.getweidu () + "\ n" + "place Name:" + Loc.getdiming ());}} ). Start ();
SOURCE download
How to get the Android GPS