@@ -0,0 +1,3208 @@
+package io.mobeacon.sdk;%0A%0Aimport android.content.Context;%0Aimport android.location.Location;%0Aimport android.os.Bundle;%0Aimport android.util.Log;%0A%0Aimport com.google.android.gms.common.ConnectionResult;%0Aimport com.google.android.gms.common.api.GoogleApiClient;%0Aimport com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;%0Aimport com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;%0Aimport com.google.android.gms.location.LocationListener;%0Aimport com.google.android.gms.location.LocationRequest;%0Aimport com.google.android.gms.location.LocationServices;%0A%0A/**%0A * Created by maxulan on 22.07.15.%0A */%0Apublic class LocationManager implements ConnectionCallbacks, OnConnectionFailedListener, LocationListener %7B%0A    private static final String TAG = %22MobeaconLocationManager%22;%0A%0A    private Context ctx;%0A    private GoogleApiClient mGoogleApiClient;%0A    private LocationRequest mLocationRequest;%0A%0A    public LocationManager(Context ctx) %7B%0A        this.ctx = ctx;%0A        buildGoogleApiClient();%0A        createLocationRequest();%0A        mGoogleApiClient.connect();%0A    %7D%0A%0A    protected synchronized void buildGoogleApiClient() %7B%0A        mGoogleApiClient = new GoogleApiClient.Builder(ctx)%0A                .addConnectionCallbacks(this)%0A                .addOnConnectionFailedListener(this)%0A                .addApi(LocationServices.API)%0A                .build();%0A    %7D%0A    @Override%0A    public void onConnected(Bundle connectionHint) %7B%0A        Location mLastLocation = LocationServices.FusedLocationApi.getLastLocation(%0A                mGoogleApiClient);%0A        if (mLastLocation != null) %7B%0A            Log.i(TAG, String.format(%22Current location. Latitude=%25d Longitude=%25d%22, mLastLocation.getLatitude(), mLastLocation.getLongitude()));%0A        %7D%0A        else  %7B%0A            Log.e(TAG, %22Connected but failed to receive last location%22);%0A        %7D%0A        startLocationUpdates();%0A    %7D%0A%0A    @Override%0A    public void onConnectionSuspended(int var1) %7B%0A        Log.e(TAG, %22Google play services connection suspended%22);%0A    %7D%0A%0A    public void onConnectionFailed(ConnectionResult var1)%7B%0A        Log.e(TAG, %22Google play services connection failed: %22 + var1.toString());%0A    %7D%0A%0A    private void createLocationRequest() %7B%0A        mLocationRequest = new LocationRequest();%0A        mLocationRequest.setInterval(10000);%0A        mLocationRequest.setFastestInterval(5000);%0A        mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);%0A    %7D%0A    /**%0A     * Requests location updates from the FusedLocationApi.%0A     */%0A    private void startLocationUpdates() %7B%0A        // The final argument to %7B@code requestLocationUpdates()%7D is a LocationListener%0A        // (http://developer.android.com/reference/com/google/android/gms/location/LocationListener.html).%0A        LocationServices.FusedLocationApi.requestLocationUpdates(%0A                mGoogleApiClient, mLocationRequest, this);%0A    %7D%0A    public void onLocationChanged(Location loc) %7B%0A        if (loc != null) %7B%0A            Log.i(TAG, String.format(%22location update: Latitude=%25d Longitude=%25d%22, loc.getLatitude(), loc.getLongitude()));%0A        %7D%0A        else  %7B%0A            Log.e(TAG, %22Failed to update location%22);%0A        %7D%0A    %7D%0A%0A%7D%0A

Work started on device location discovery