Android GPS detailed explanation and sample code

Lbs (location based services) is a location-based service, which has at least two meanings. First, it should be easy to obtain the current geographical location, such as longitude, latitude, altitude, etc. the other is to provide value-added services based on the current location, such as looking for nearby gas stations, restaurants, hotels, etc. The first step: get the user's current location, and we can get it with Android's GPS positioning service. Android provides two kinds of positioning services: network-based positioning service and satellite based positioning service. The first three items in settings - > location and security settings are that the last enhanced GPS is to help quickly find satellites.

So let's write a simple program to get the current location.

1. New project lesson26_ GPSLocation

2、MainActivity. The Java code is as follows:

3、main. XML, I won't post the code, just a button and a text box. I'll see the screenshot later.

4. You want to create a new version of Android manifest Add permissions to XML:

5. Compile and run the program on the real machine and view the results:

Here I want to explain that I failed to submit the simulator data on the simulator, and the test on the real machine is not very smooth. Once it is related to the hardware, there will always be some inexplicable errors

The above is the introduction and simple example of Android GPS. I hope to help students in need. Thank you for your support for this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>