Java Code Examples for com.google.android.gms.location.LocationSettingsStates#fromIntent()

The following examples show how to use com.google.android.gms.location.LocationSettingsStates#fromIntent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WhereAmIActivity.java    From Wrox-ProfessionalAndroid-4E with Apache License 2.0 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode,
                                int resultCode,Intent data){
  final LocationSettingsStates states = LocationSettingsStates.fromIntent(data);

  if (requestCode == REQUEST_CHECK_SETTINGS) {
    switch (resultCode) {
      case Activity.RESULT_OK:
        // Requested changes made, request location updates.
        requestLocationUpdates();
        break;
      case Activity.RESULT_CANCELED:
        // Requested changes were NOT made.
        Log.d(TAG, "Requested settings changes declined by user.");
        // Check if any location services are available, and if so
        // request location updates.
        if (states.isLocationUsable())
          requestLocationUpdates();
        else
          Log.d(TAG, "No location services available.");
        break;
      default: break;
    }
  }
}
 
Example 2
Source File: LocationActivity.java    From Wrox-ProfessionalAndroid-4E with Apache License 2.0 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){

  final LocationSettingsStates states = LocationSettingsStates.fromIntent(data);

  if (requestCode == REQUEST_CHECK_SETTINGS) {
    switch (resultCode) {
      case Activity.RESULT_OK:
        // TODO Changes were applied.
        break;
      case Activity.RESULT_CANCELED:
        // TODO Changes were not applied.
        // TODO Check states to confirm if we can attempt
        // TODO to request location updates anyway.
        break;
      default: break;
    }
  }
}
 
Example 3
Source File: WhereAmIActivity.java    From Wrox-ProfessionalAndroid-4E with Apache License 2.0 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode,
                                int resultCode,Intent data){
  final LocationSettingsStates states = LocationSettingsStates.fromIntent(data);

  if (requestCode == REQUEST_CHECK_SETTINGS) {
    switch (resultCode) {
      case Activity.RESULT_OK:
        // Requested changes made, request location updates.
        requestLocationUpdates();
        break;
      case Activity.RESULT_CANCELED:
        // Requested changes were NOT made.
        Log.d(TAG, "Requested settings changes declined by user.");
        // Check if any location services are available, and if so
        // request location updates.
        if (states.isLocationUsable())
          requestLocationUpdates();
        else
          Log.d(TAG, "No location services available.");
        break;
      default: break;
    }
  }
}
 
Example 4
Source File: WhereAmIActivity.java    From Wrox-ProfessionalAndroid-4E with Apache License 2.0 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode,
                                int resultCode,Intent data){
  final LocationSettingsStates states = LocationSettingsStates.fromIntent(data);

  if (requestCode == REQUEST_CHECK_SETTINGS) {
    switch (resultCode) {
      case Activity.RESULT_OK:
        // Requested changes made, request location updates.
        requestLocationUpdates();
        break;
      case Activity.RESULT_CANCELED:
        // Requested changes were NOT made.
        Log.d(TAG, "Requested settings changes declined by user.");
        // Check if any location services are available, and if so
        // request location updates.
        if (states.isLocationUsable())
          requestLocationUpdates();
        else
          Log.d(TAG, "No location services available.");
        break;
      default: break;
    }
  }
}
 
Example 5
Source File: WhereAmIActivity.java    From Wrox-ProfessionalAndroid-4E with Apache License 2.0 6 votes vote down vote up
@Override
protected void onActivityResult(int requestCode,
                                int resultCode,Intent data){
  final LocationSettingsStates states = LocationSettingsStates.fromIntent(data);

  if (requestCode == REQUEST_CHECK_SETTINGS) {
    switch (resultCode) {
      case Activity.RESULT_OK:
        // Requested changes made, request location updates.
        requestLocationUpdates();
        break;
      case Activity.RESULT_CANCELED:
        // Requested changes were NOT made.
        Log.d(TAG, "Requested settings changes declined by user.");
        // Check if any location services are available, and if so
        // request location updates.
        if (states.isLocationUsable())
          requestLocationUpdates();
        else
          Log.d(TAG, "No location services available.");
        break;
      default: break;
    }
  }
}