2013-05-31 123 views
0

从IntentService中,我如何进行异步调用并避免在回调到达之前关闭服务?来自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"); 
     } 
    }); 
} 

回答

0

你没有打电话给LocationClient.connect()

无论如何,你为什么要打个电话给IntentService?它被设计用于在后台工作,并在没有更多工作安排时被销毁。使用正常的Service