How to get last known location for Location manager in Android?

后端 未结 7 1386
-上瘾入骨i
-上瘾入骨i 2021-01-11 10:34

I am using simple location manager object to get lastKnownLocation() of device but getting null object in

7条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-11 10:48

                // Get the location from the given provider
                Location location = locationManager
                        .getLastKnownLocation(provider);
    
                locationManager.requestLocationUpdates(provider, 1000, 1, this);
    

提交回复
热议问题