本文整理匯總了Java中com.google.android.gms.location.LocationSettingsStatusCodes類的典型用法代碼示例。如果您正苦於以下問題:Java LocationSettingsStatusCodes類的具體用法?Java LocationSettingsStatusCodes怎麽用?Java LocationSettingsStatusCodes使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LocationSettingsStatusCodes類屬於com.google.android.gms.location包,在下文中一共展示了LocationSettingsStatusCodes類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleLocationStatusResult
import com.google.android.gms.location.LocationSettingsStatusCodes; //導入依賴的package包/類
private void handleLocationStatusResult(@NonNull Status status) {
if (mResolvingError) {
// Already attempting to resolve an error.
return;
}
if (status.getStatusCode() == LocationSettingsStatusCodes.RESOLUTION_REQUIRED) {
try {
status.startResolutionForResult(this, REQUEST_RESOLVE_ERROR);
// TODO: mieux gérer mResolvingError (attendre la résolution)
mResolvingError = true;
} catch (IntentSender.SendIntentException e) {
// There was an error with the resolution intent. Try again.
// TODO: mieux notifier le service
// mGoogleApiClient.connect();
MainActivity.this.startService(mCollecteServiceIntent);
mResolvingError = false;
}
} else {
// TODO: couper l'application ?
mResolvingError = true;
showErrorDialog(status.getStatusCode());
}
}
示例2: onResult
import com.google.android.gms.location.LocationSettingsStatusCodes; //導入依賴的package包/類
@Override
public void onResult(LocationSettingsResult result) {
final Status status = result.getStatus();
switch (status.getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
// All location settings are satisfied -> nothing to do
callSuccessCallback();
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
// Location settings are not satisfied. Show the user a dialog to upgrade location settings
try {
// Show the dialog by calling startResolutionForResult(), and check the result
status.startResolutionForResult(mActivity, REQUEST_CHECK_SETTINGS);
} catch (IntentSender.SendIntentException e) {
Log.e(TAG, "PendingIntent unable to execute request.", e);
callErrorCallback();
}
break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
Log.e(TAG, "Location settings are inadequate, and cannot be fixed here. Dialog not created.");
callErrorCallback();
break;
}
}
示例3: onResult
import com.google.android.gms.location.LocationSettingsStatusCodes; //導入依賴的package包/類
@Override
public void onResult(@NonNull LocationSettingsResult locationSettingsResult) {
final Status status = locationSettingsResult.getStatus();
switch (status.getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
// All location settings are satisfied. The client can
// initialize location requests here.
continueGPSOperation();
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
// Location settings are not satisfied, but this can be fixed
// by showing the user a dialog.
_result.error("LOCATION DISABLED",
"This Android device has it's location disabled",
null);
break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
// Location settings are not satisfied. However, we have no way
// to fix the settings so we won't show the dialog.
_result.error("LOCATION DISABLED",
"This Android device has it's location disabled",
null);
break;
}
}
示例4: onConnected
import com.google.android.gms.location.LocationSettingsStatusCodes; //導入依賴的package包/類
@Override
public void onConnected(@Nullable Bundle bundle) {
LocationRequest locationRequest = createLocationRequest();
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest);
PendingResult<LocationSettingsResult> locationSettingsResultPendingResult = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
locationSettingsResultPendingResult
.setResultCallback(new ResultCallback<LocationSettingsResult>() {
@Override
public void onResult(LocationSettingsResult result) {
if (LocationSettingsStatusCodes.SUCCESS != result.getStatus().getStatusCode()) {
if (result.getStatus().hasResolution()) {
handleLocationStatusResult(result.getStatus());
} else {
// TODO: faire quelque chose
}
}
}
});
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// la demande des droits est faite ailleurs
return;
}
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, locationRequest, this);
onLocationChanged(LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient));
}
示例5: configureLocationConnection
import com.google.android.gms.location.LocationSettingsStatusCodes; //導入依賴的package包/類
private void configureLocationConnection() {
LocationRequest locationRequest = createLocationRequest();
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(locationRequest);
PendingResult<LocationSettingsResult> locationSettingsResultPendingResult = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
locationSettingsResultPendingResult
.setResultCallback(new ResultCallback<LocationSettingsResult>() {
@Override
public void onResult(LocationSettingsResult result) {
if (LocationSettingsStatusCodes.SUCCESS != result.getStatus().getStatusCode()) {
Intent localIntent = new Intent(Constants.GOOGLE_API).putExtra(Constants.GOOGLE_API_LOCATION_RESULT, result.getStatus());
LocalBroadcastManager.getInstance(ParcoursService.this).sendBroadcast(localIntent);
}
}
});
// noinspection MissingPermission : permissions dans le manifest
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, locationRequest, this);
}
示例6: onResult
import com.google.android.gms.location.LocationSettingsStatusCodes; //導入依賴的package包/類
@Override
public void onResult(@NonNull LocationSettingsResult r) {
switch (r.getStatus().getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
gpsIsTurnedOn = true;
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
try {
r.getStatus().startResolutionForResult(activity, SideBarActivity.REQUEST_CHECK_SETTINGS);
} catch (IntentSender.SendIntentException ignored) {
ignored.printStackTrace();
}
break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
gpsIsTurnedOn = false;
break;
}
}
示例7: onConnected
import com.google.android.gms.location.LocationSettingsStatusCodes; //導入依賴的package包/類
/**
* GoogleApiClient interfaces
*/
@Override
public void onConnected(@Nullable Bundle bundle) {
final LocationRequest locationRequest = LocationRequest.create()
.setPriority(LocationRequest.PRIORITY_LOW_POWER);
final LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
.addLocationRequest(locationRequest)
.setNeedBle(true);
final PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
result.setResultCallback(new ResultCallback<LocationSettingsResult>() {
@Override
public void onResult(@NonNull LocationSettingsResult locationSettingsResult) {
final Status status = locationSettingsResult.getStatus();
if (status.getStatusCode() == LocationSettingsStatusCodes.RESOLUTION_REQUIRED) {
try {
status.startResolutionForResult(getCurrentActivity(), NEAR_LOCATION_SETTINGS_CODE);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
}
}
});
}
示例8: onResult
import com.google.android.gms.location.LocationSettingsStatusCodes; //導入依賴的package包/類
@Override
public void onResult(@NonNull LocationSettingsResult locationSettingsResult) {
final Status status = locationSettingsResult.getStatus();
switch (status.getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
startLocationUpdates();
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
try {
status.startResolutionForResult(LocationActivity.this, REQUEST_CHECK_LOCATION_SETTINGS);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
Log.i(TAG, "PendingIntent unable to execute request.");
}
break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
Log.i(TAG, "Location settings are inadequate, and cannot be fixed here. Dialog not created.");
break;
}
}
示例9: onResult
import com.google.android.gms.location.LocationSettingsStatusCodes; //導入依賴的package包/類
@Override
public void onResult(@NonNull LocationSettingsResult result) {
final Status status = result.getStatus();
switch (status.getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
mLocationActivityListener.onSettingsCheckSuccess();
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
try {
startResolvingSettingsProblem(status);
} catch (IntentSender.SendIntentException e) {
mLocationActivityListener.onSettingsCheckFailure();
}
break;
default:
mLocationActivityListener.onSettingsCheckFailure();
break;
}
}
示例10: onResult
import com.google.android.gms.location.LocationSettingsStatusCodes; //導入依賴的package包/類
@Override
public void onResult(LocationSettingsResult result) {
Status status = result.getStatus();
switch (status.getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
wasSending = JappPreferences.isUpdatingLocationToServer();
if (!wasSending) {
showLocationNotification("Japp verzendt je locatie niet!", Color.rgb(244, 66, 66));
} else {
showLocationNotification("Japp verzendt je locatie", Color.rgb(113, 244, 66));
}
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
if(listener != null) {
listener.onResolutionRequired(status);
}
break;
}
}
示例11: onResult
import com.google.android.gms.location.LocationSettingsStatusCodes; //導入依賴的package包/類
@Override
public void onResult(LocationSettingsResult result) {
final Status status = result.getStatus();
switch (status.getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
// All location settings are satisfied. The client can
// initialize location requests here.
startLocationUpdates();
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
// Location settings are not satisfied, but this can be fixed
// by showing the user a dialog.
break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
// Location settings are not satisfied. However, we have no way
// to fix the settings so we won't show the dialog.
break;
}
}
示例12: onResult
import com.google.android.gms.location.LocationSettingsStatusCodes; //導入依賴的package包/類
@Override
public void onResult(LocationSettingsResult locationSettingsResult) {
final Status status = locationSettingsResult.getStatus();
switch (status.getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
Log.i(LOG_TAG, "All location settings are satisfied.");
startLocationUpdates();
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
Log.i(LOG_TAG, "Location settings are not satisfied. Show the user a dialog to" +
"upgrade location settings ");
try {
// Show the dialog by calling startResolutionForResult(), and check the result
// in onActivityResult().
status.startResolutionForResult(MainActivity.this, REQUEST_CHECK_SETTINGS);
} catch (IntentSender.SendIntentException e) {
Log.i(LOG_TAG, "PendingIntent unable to execute request.");
}
break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
Log.i(LOG_TAG, "Location settings are inadequate, and cannot be fixed here. Dialog " +
"not created.");
break;
}
}
示例13: onResult
import com.google.android.gms.location.LocationSettingsStatusCodes; //導入依賴的package包/類
@Override
public void onResult(LocationSettingsResult locationSettingsResult) {
final Status status = locationSettingsResult.getStatus();
switch (status.getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
Log.i(TAG, "All location settings are satisfied.");
GetLastLocation();
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
Log.i(TAG, "Location settings are not satisfied. Show the user a dialog to" +
"upgrade location settings ");
try {
// Show the dialog by calling startResolutionForResult(), and check the result
// in onActivityResult().
status.startResolutionForResult(mActivity, REQUEST_CHECK_SETTINGS);
} catch (IntentSender.SendIntentException e) {
ErrorHappened("PendingIntent unable to execute request.");
}
break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
ErrorHappened("Location settings are inadequate, and cannot be fixed here. Dialog " +
"not created.");
break;
}
}
示例14: isLocationEnabled
import com.google.android.gms.location.LocationSettingsStatusCodes; //導入依賴的package包/類
@Override
protected boolean isLocationEnabled() {
if (mLastStatus != null) {
if (mLastStatus.hasResolution()) {
try {
startIntentSenderForResult(mLastStatus.getResolution().getIntentSender(),
REQUEST_LOCATION, null, 0, 0, 0, null);
}
catch (IntentSender.SendIntentException e) {
Toast.makeText(getContext(), R.string.err_location_access_unknown_error,
Toast.LENGTH_LONG).show();
}
}
else if (mLastStatus.getStatusCode() == LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE) {
// no location no party!
Toast.makeText(getContext(), R.string.err_location_access_unknown_error,
Toast.LENGTH_LONG).show();
}
return false;
}
return true;
}
示例15: isLocationEnabled
import com.google.android.gms.location.LocationSettingsStatusCodes; //導入依賴的package包/類
protected boolean isLocationEnabled() {
if (mLastStatus != null) {
if (mLastStatus.hasResolution()) {
try {
startIntentSenderForResult(mLastStatus.getResolution().getIntentSender(),
REQUEST_LOCATION, null, 0, 0, 0, null);
}
catch (IntentSender.SendIntentException e) {
Toast.makeText(getContext(), R.string.err_location_access_unknown_error,
Toast.LENGTH_LONG).show();
}
}
else if (mLastStatus.getStatusCode() == LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE) {
// no location no party!
Toast.makeText(getContext(), R.string.err_location_access_unknown_error,
Toast.LENGTH_LONG).show();
}
return false;
}
return true;
}