Code example for LocationClient

0
 
  private void setUpLocationClientIfNeeded() { 
    if (mLocationClient == null) {
      mLocationClient = new LocationClient(
          getApplicationContext(), 
          this,  // ConnectionCallbacks
          this); // OnConnectionFailedListener
    } 
  } 
 
  /** 
   * Button to get current Location. This demonstrates how to get the current Location as required, 
   * without needing to register a LocationListener. 
   */ 
  public void showMyLocation(View view) {
    if (mLocationClient != null && mLocationClient.isConnected()) {
      String msg = "Location = " + mLocationClient.getLastLocation();
      Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show();
    } 
  }