Clear fused location provider's location for testing

此生再无相见时 提交于 2019-12-20 03:29:05

问题


I would like to know if it is possible to clear the "location" that is stored by play service's fused location API. When testing my app on a real device, I would like to recreate few scenarios and that's the reason I would like to know if this is possible.

I tried to clear "Google Play Services" cache and data. But, it does not seem to help me. Location still seems to be cached somewhere.


回答1:


Google Play Services is central service and serves every app installed on your device. After clearing cache and data, if any app connects with Google Play services on that device(which almost every Google app do), then Fused location api will fetch and save location for that app. After that once your app fetches last known location in onConnected, it will return the location.

It is hard to simulate the scenario your are trying to achieve unless you hard code the values to be blank.




回答2:


I just disabled the GPS then restarted the Android phone & I found that the locationManager.getLastKnownLocation returned NULL for location.



来源:https://stackoverflow.com/questions/37778338/clear-fused-location-providers-location-for-testing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!