Couldn't get user location

后端 未结 3 794
-上瘾入骨i
-上瘾入骨i 2021-01-26 05:39

I am trying to get user location either network location or gps location or both. for that i am running a background service which implements LocationListener

3条回答
  •  礼貌的吻别
    2021-01-26 06:03

    As you said, you are not even getting toast of "Getting location Via Network". So your execution is not going inside the if block of

    if (lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
    
    }
    

    So make sure you have checked

    Google's location services - Checked

    in your device Settings.

    Settings > location services > Google's location services and Access Location.

    Then you should get location from LocationManager. Else rest of your code looks fine.

    Hope this helps.

    Reference link

提交回复
热议问题