Simply realize the continuous positioning of anzhuoli Baidu map

In recent days, I have studied the problem of developing Android maps on local mobile phones and found that the explanation of Baidu's continuous positioning in Baidu's official example demo is still unclear. After several studies, I have made it more detailed to facilitate your study. If there are deficiencies, please point out them in the comment area, The website of the official example is: http://lbsyun.baidu.com/index.php?title=android -locsdk/guide/v5-0

The above website has explained the simple configuration of Android and Baidu map environment in detail. I won't repeat it again. In addition, someone may find it

This is about mlocationclient. Stop(); mLocationClient.start(); mLocationClient.requestLocation(); It is necessary for me to explain these three functions, because the combination of these three functions is very important during continuous positioning. It is explained in the official document that the mlocationclient. Start() function is used to start positioning, and the mlocationclient. Requestlocation() function is used to actively trigger the internal positioning logic of the positioning SDK. Personally, I feel the same, Both of them will execute the logic code in the class of my mlocationclient, which may be my project, and then mlocationclient. Stop(). This function is used to stop positioning. If positioning continues, it needs to be used in combination with mlocationclient. Start() function, which is shown in the above code.

Remember not to use mlocationclient. Start() and mlocationclient. Stop() together. When I query online, I seem to say some reasons. Give an example:

Therefore, in my mainactivity, I use threads to execute start and stop functions over and over again, which will eliminate the effect just mentioned, and finally achieve continuous positioning.

Here is my layout file to see

For other configurations such as permissions, just use the official address given at the beginning

By the way, I developed with Android version 4.2. There will be some errors in the positioning time interval between mobile phone real machine debugging and virtual machine debugging. I don't know why

The above is the whole content of this article. I hope the content of this article can bring some help to your study or work. At the same time, I also hope to support a lot of programming tips!

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
分享
二维码
< <上一篇
下一篇>>