我正在开发一个android应用程序,我创建了一个
LocationListener我将我的位置发送到服务器的服务,一切都在工作,除了
stopservice()服务一直在运行,有没有解决这个问题的办法?
发布于 2015-04-20 23:31:50
在您的服务中,只需在完成位置更新后调用stopSelf():
MyLocationService.this.stopSelf();此外,根据您使用的是过时的import android.location.LocationListener还是新的import com.google.android.gms.location.LocationListener,您需要onDestory服务器,删除位置侦听器的更新或断开API客户端:
旧的:
@Override
public void onDestroy() {
if (myLocationListener) {
myLocationManager.removeUpdates(myLocationListiener);
}
}新的:
@Override
public void onDestroy() {
if (myGoogleApiClient) {
myGoogleApiClient.disconnect();
}
}https://stackoverflow.com/questions/29751483
复制相似问题