开发者

Android requestLocationUpdates with a 15 minute interval is causing gps indicator to fire constantly

this is the requestLocationUpdates call I am using, 900000 (15 minutes) and 500 meters shouldn't be causing the gps to fire constantly, its really draining battery...

I know this code isn't helpful.. But does anyone know why this might be happening?

in my onStartCommand

mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 900000, 500, locationListener);
mLocation = mlocManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

and then

private final LocationListener locationListener = new LocationListener() {
    public void onLocationChanged(Location location) {
        mLocation = locati开发者_如何转开发on;
    }

    @Override
    public void onProviderDisabled(String arg0) {}
    @Override
    public void onProviderEnabled(String arg0) {}
    @Override
    public void onStatusChanged(String arg0, int arg1, Bundle arg2) {}
};


The time parameter to requestLocationUpdates() is a hint, not a rule -- you may get locations more frequently than this.

If you want to stop consuming battery due to having the GPS on, call removeUpdates().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜