从 IntentService 中,如何进行异步调用并避免在回调到达之前关闭服务?
目前既没有 onConnected 也没有 onConnectionFailed 被调用:
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");
}
});
}