小编Ban*_*der的帖子

requestLocationUpdates在Android中的间隔不会更新

我有一个问题,我的服务实现了LocationListener,它似乎每500毫秒接收一次GPSupdate.无论我在requestLocationUpdates函数中放入什么minTime.

我的代码片段:

public class LocationService extends Service implements LocationListener {

    LocationManager locMan;

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {

        locMan = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 
        locMan.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER;
        locMan.requestLocationUpdates( LocationManager.GPS_PROVIDER, 60000, 1, this); 

    }

    public void onLocationChanged(Location location) {
        Log.d( "Loc", "Location has been changed" );
    }
}
Run Code Online (Sandbox Code Playgroud)

从我的主要活动中的一个按钮,我将调用startService(),之后它应该在后台运行,但它会提供持续的更新.

gps android location locationmanager

5
推荐指数
1
解决办法
3131
查看次数

标签 统计

android ×1

gps ×1

location ×1

locationmanager ×1