Couldn't get user location

后端 未结 3 801
-上瘾入骨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 05:58

    // The minimum distance to change Updates in meters
    private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
    
    // The minimum time between updates in milliseconds
    private static final long MIN_TIME_BW_UPDATES = 1000 * 60 * 1; // 1 minute
    
    locationManager.requestLocationUpdates(
                                LocationManager.GPS_PROVIDER,
                                MIN_TIME_BW_UPDATES,
                                MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
    

    or

    lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10, 1000*60*1, this);
    

提交回复
热议问题