Code example for LocationClient

Methods: getLastLocation, isConnected

0
            if(sensorEvent.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
                mGravity = sensorEvent.values;
            } else if(sensorEvent.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {
                mGeomagnetic = sensorEvent.values;
            } 
            if(mLocationClient.isConnected()) {
                mLocation = mLocationClient.getLastLocation();
            } 
            notifyListener(); 
        } 
 
        public void onAccuracyChanged(Sensor sensor, int i) { }
        public void onConnected(Bundle bundle) { }
        public void onDisconnected() { } 
        public void onConnectionFailed(ConnectionResult connectionResult) { }
    } 
 
    private boolean notifyListener() { 
        if(this.mGravity != null && this.mGeomagnetic != null && this.mLocation != null) {
            float[] R = new float[16];
            float[] I = new float[16];