I'm using Google Play Services for Location in my Android app. This is my first app so I'm not expecting that I have utilized everything perfectly.My app is to get GPS/Date and send to a server database. I was hoping to learn (and everything works so far) if I've used Google Play Services code properly.I can only test via Android Studio Project emulator as well.public class MainActivity extends Activity implements ConnectionCallbacks,    OnConnectionFailedListener {private static final String TAG = MainActivity.class.getSimpleName();private final static int PLAY_SERVICES_RESOLUTION_REQUEST = 1000;private GoogleApiClient mGoogleApiClient;private Location mLastLocation;private String mFormattedDate;List<MyTask> tasks;private Button btnNewShowLocation;View v;@Overrideprotected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.activity_main);    btnNewShowLocation = (Button) findViewById(R.id.btnNewShowLocation);    tasks = new ArrayList<>();    if (checkPlayServices()) {        buildGoogleApiClient();    }    btnNewShowLocation.setOnClickListener(new View.OnClickListener() {        @Override        public void onClick(View v) {            if (checkPlayServices()) {                requestData(http://10.0.2.2/index.php);            } else {                Toast.makeText(MainActivity.this, Network isn't available, Toast.LENGTH_LONG).show();            }        }    });}private void displayLocation() {    mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);    Calendar c = Calendar.getInstance();    System.out.println(Current time =&gt;  + c.getTime());    SimpleDateFormat df = new SimpleDateFormat(yyyy-MM-dd HH:mm);    mFormattedDate = df.format(c.getTime());    if (mLastLocation != null) {        double latitude = mLastLocation.getLatitude();        double longitude = mLastLocation.getLongitude();    } else {        Toast.makeText(getApplicationContext(), Location not found! \nCheck Location in Settings., Toast.LENGTH_LONG).show();    }}private void requestData(String uri) {    RequestPackage p = new RequestPackage();    p.setMethod(POST);    p.setUri(uri);    p.setParams(longitude,    String.valueOf(mLastLocation.getLongitude()));    p.setParams(latitude,     String.valueOf(mLastLocation.getLatitude()));    p.setParams(date,         String.valueOf(mFormattedDate));    p.setParams(boolean,      true);    MyTask task = new MyTask();    task.execute(p);}protected synchronized void buildGoogleApiClient() {    mGoogleApiClient = new GoogleApiClient.Builder(this)            .addConnectionCallbacks(this)            .addOnConnectionFailedListener(this)            .addApi(LocationServices.API).build();}/** * Method to verify google play services on the device */private boolean checkPlayServices() {    int resultCode = GooglePlayServicesUtil            .isGooglePlayServicesAvailable(this);    if (resultCode != ConnectionResult.SUCCESS) {        if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {            GooglePlayServicesUtil.getErrorDialog(resultCode, this,                    PLAY_SERVICES_RESOLUTION_REQUEST).show();        } else {            Toast.makeText(getApplicationContext(),                    This device is not supported., Toast.LENGTH_LONG)                    .show();            finish();        }        return false;    }    return true;}@Overrideprotected void onStart() {    super.onStart();    if (mGoogleApiClient != null) {        mGoogleApiClient.connect();    }}@Overrideprotected void onResume() {    super.onResume();    checkPlayServices();}/** * Google api callback methods */@Overridepublic void onConnectionFailed(ConnectionResult result) {    // what's going on here...    Log.i(TAG, Connection failed:  ConnectionResult.getErrorCode() =             + result.getErrorCode());}@Overridepublic void onConnected(Bundle arg0) {    displayLocation();}@Overridepublic void onConnectionSuspended(int arg0) {    mGoogleApiClient.connect();}}
Android Google Play Services code for GPS
java;android