コード例 #1
0
  @Override
  protected void onHandleIntent(Intent intent) {
    Log.d(TAG, "handle new location request.");

    int seq = intent.getIntExtra("seq", -1);
    String type = intent.getStringExtra("type");
    String id = intent.getStringExtra("id");
    if (TextUtils.isEmpty(type) || TextUtils.isEmpty(id)) {
      Log.d(TAG, "LocationIntentService got invaild intent.");
      return;
    }

    synchronized (mSyncObject) {
      if (mLocationClient != null) {
        int retCode = mLocationClient.requestLocation();
        Log.d(TAG, "retCode:" + retCode);
        try {
          mSyncObject.wait();
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
      }
    }
    if (MainActivity.VISIBLE
        || !PrefUtil.getbooleanValue(getApplicationContext(), "pref_loc_me_silent_enable", false)) {
      MessageHelper.sendServerMsgToList(
          seq, "client", getString(R.string.loc_sending_loc), getApplicationContext());
    }
    sendResultToServer(formatResponse(id));
    Log.d(TAG, "LocationIntentService exit intent.");
  }
コード例 #2
0
 private void sendResultToServer(String broadcast) {
   MessageHelper.sendBackgroundMsgToServer(getApplicationContext(), broadcast);
 }