2013-05-31 44 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