Android 来自IntentService的异步调用
从IntentService,如何进行异步调用并避免在回调到达之前关闭服务 当前未调用OnConnectiond或onConnectionFailed:Android 来自IntentService的异步调用,android,location,intentservice,google-play-services,Android,Location,Intentservice,Google Play Services,从IntentService,如何进行异步调用并避免在回调到达之前关闭服务 当前未调用OnConnectiond或onConnectionFailed: private void initLocationUpdates() { Log.d(TAG, "initLocationUpdates"); locationClient = new LocationClient(this, new ConnectionCallbacks() { @Override
private void initLocationUpdates() {
Log.d(TAG, "initLocationUpdates");
locationClient = new LocationClient(this, new ConnectionCallbacks() {
@Override
public void onDisconnected() {
Log.d(TAG, "onDisconnected");
}
@Override
public void onConnected(Bundle arg0) {
Log.d(TAG, "onConnected");
LocationRequest request = new LocationRequest();
request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
request.setInterval(5);
locationClient.requestLocationUpdates(request, locationChangedPendingIntent);
}
}, new OnConnectionFailedListener() {
@Override
public void onConnectionFailed(ConnectionResult arg0) {
Log.d(TAG, "onConnectionFailed");
}
});
}
你没打电话
不管怎样,为什么要从IntentService
调用此函数?它被设计为在后台工作,当没有更多的工作计划时,它将被销毁。使用普通服务