Android pit filling series: example of location request pop-up box after releasing location permission on models such as Xiaomi series

background

Recently, due to the needs of the actual project, the positioning request is triggered under specific operations to get the user's location and nearby locations.

Question:

After preliminary selection, it was finally decided to access Baidu positioning. According to the Android documents of Baidu positioning SDK, the access process was relatively smooth. However, it was later found that on some models such as Xiaomi series, after entering the app, "trying to locate your mobile phone through the network or satellite" will appear. It affects the user experience.

Resolution process:

1. Flurry's pit

Several third-party SDKs have been introduced into the project, mainly including flurry, Youmeng, getui, baidu positioning SDK, etc. In the execution flow of APP startup initialization and entering the home page, it mainly involves flurry, Youmeng and personal push.

By searching locationmanager one by one in all the third-party SDK jar packages introduced into the project, it is found that only flurry and Baidu positioning contain. Therefore, it was initially positioned to flurry. After removing the flurry, it is found that the positioning request pop-up box appears as soon as entering the app on such models, and the scene does disappear.

Finally, the corresponding switch interface is found in the official document of Flurry: flurryagent setReportLocation(boolean); This method directly determines whether flurry reports user address and location information, and its default value is true.

Therefore, after init to flurry, call flurryagent directly setReportLocation(false); Test again, and the above problems must be solved.

2. Kindness of Youmeng

I thought the problem was over. I didn't want to see the pop-up box of location request on Xiaomi series and other models from time to time in the subsequent use process. After careful verification, it didn't trigger its own location request in the app at this time, and the main problem is: it appears from time to time. It's too weird!

I consulted some information on the Internet and didn't have a good clue. However, the above flurry solution process gives some ideas. Since flurry will obtain geographic location information by default when it has location permission, will other SDKs be similar? With curiosity, I read the class file of Youmeng,

I found one of the methods setautolocation (Boolean). Ha, it's the same as flurry. However, a strange phenomenon is found that the setautolocation method in the alliance has been abandoned.

It has been abandoned and turned into an empty method. Will it be the hegemony of Youmeng, which even doesn't provide a switch interface to the app when secretly obtaining geographic location information?

This switching method has been abandoned. There must be a reason. Finally, the old version of this method is found. There is no abandoned Youmeng SDK. Comparing the class file, it is found that the locationmanager method exists in the old version of Youmeng SDK, but there is no new version. In addition, some people also talked about this issue at the alliance forum, and after removing the alliance,

After a large number of tests, it is found that this problem does exist. It seems that Youmeng is still very kind and directly removes the acquisition of user positioning information, so this switching method is of course abandoned.

3. Doubts about Baidu's positioning

Baidu positioning SDK documents require positioning permission

In fact, it has access_ FINE_ The location permission has access_ COARSE_ Location permission. A large number of test results show that when the GPS on the mobile phone is turned on, the probability of positioning pop-up box is large, and Baidu positioning adopts mixed positioning mode, so the actual needs of the project do not need accurate positioning,

If the rough positioning can meet the requirements, will it have something to do with permissions, so access_ FINE_ Change location to access_ COARSE_ Location, and through the horizontal comparison with other apps after reverse solution, it is found that other apps using Baidu positioning only use rough positioning permission, which is resolutely changed.

After modification, it was found that the probability of irregular occurrence of positioning bullet frame was indeed reduced.

Baidu positioning configuration also has the following service configuration

In the actual test, it is found that if the permission is access_ FINE_ Location, adding Android: exported = "false" to the service configuration here also reduces the occurrence probability of positioning pop ups to a certain extent,

Add here decisively.

4. Pit goods pushed

After the above modification, the probability of occasional location request pop-up frame is relatively small. Once in a long time. So who triggered the location request? Under a large number of tests, it is found that this problem becomes inevitable after modifying the system time.

Now that we have found a strange and inevitable path, it is much easier to locate. Decisively remove Baidu positioning, Youmeng and flurry. However, the location permission is reserved, and this problem is still necessary under the above necessary path.

Remove the related problems such as push initialization, and this problem will disappear decisively under the above necessary path. I found you, push!!

I thought some kind-hearted people should provide switch interface like flurry and the old version of Youmeng, but I was disappointed!

Contact the so-called technical support of a push. The other party affirmed that a push obtains the location information first when it has the location permission, but the answer to the switch interface question is natural and unrestrained!

But it does affect the user experience!!

At this point, the problem of many days of confusion has finally found the reason. The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support 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
分享
二维码
< <上一篇
下一篇>>