本文整理了Java中com.google.android.gms.common.api.Status.startResolutionForResult()
方法的一些代码示例,展示了Status.startResolutionForResult()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Status.startResolutionForResult()
方法的具体详情如下:
包路径:com.google.android.gms.common.api.Status
类名称:Status
方法名:startResolutionForResult
[英]Resolves an error by starting any intents requiring user interaction. See CommonStatusCodes#SIGN_IN_REQUIRED, and CommonStatusCodes#RESOLUTION_REQUIRED.
[中]通过启动任何需要用户交互的意图来解决错误。请参见CommonStatusCodes#需要签名#和CommonStatusCodes#需要解析#。
代码示例来源:origin: commonsguy/cw-omnibus
result
.getStatus()
.startResolutionForResult(getActivity(),
SETTINGS_REQUEST_ID);
thingsPlumbBusted=false;
代码示例来源:origin: yayaa/LocationManager
void startSettingsApiResolutionForResult(Status status, Activity activity) throws SendIntentException {
status.startResolutionForResult(activity, RequestCode.SETTINGS_API);
}
代码示例来源:origin: florent37/RxGps
void handleIntent() {
Status status = getIntent().getParcelableExtra(ARG_STATUS);
try {
status.startResolutionForResult(this, REQUEST_CODE_RESOLUTION);
} catch (IntentSender.SendIntentException | NullPointerException e) {
setResolutionResultAndFinish(Activity.RESULT_CANCELED);
}
}
代码示例来源:origin: ShlMlkzdh/RxSmartLock
@Override
public void onError(Throwable e) {
if (e instanceof StatusException) {
Status status = ((StatusException) e).getStatus();
if (status.hasResolution()) {
try {
status.startResolutionForResult(MainActivity.this, CREDENTIAL_REQUEST_RC);
} catch (IntentSender.SendIntentException e1) {
Log.e(TAG, "STATUS: Failed to send resolution.");
}
} else {
// The user must create an account or sign in manually.
Log.e(TAG, "STATUS: Unsuccessful credential request.");
}
}
}
代码示例来源:origin: klaasnotfound/LocationAssistant
/**
* Brings up an in-app system dialog that requests a change in location provider settings.
* The settings change may involve switching on GPS and/or network providers and depends on the accuracy and
* update interval that was requested when constructing the LocationAssistant.
* Call this method only from within {@link Listener#onNeedLocationSettingsChange()}.
*/
public void changeLocationSettings() {
if (locationStatus == null) return;
if (activity == null) {
if (!quiet)
Log.e(getClass().getSimpleName(), "Need to resolve location status issues, but no activity is " +
"registered! Specify a valid activity when constructing " + getClass().getSimpleName() +
" or register it explicitly with register().");
return;
}
try {
locationStatus.startResolutionForResult(activity, REQUEST_CHECK_SETTINGS);
} catch (IntentSender.SendIntentException e) {
if (!quiet)
Log.e(getClass().getSimpleName(), "Error while attempting to resolve location status issues:\n" +
e.toString());
if (listener != null)
listener.onError(ErrorType.SETTINGS, "Could not resolve location settings issue:\n" +
e.getMessage());
changeSettings = false;
acquireLocation();
}
}
代码示例来源:origin: bkhezry/MapDrawingTools
@Override
public void onResult(@NonNull LocationSettingsResult locationSettingsResult) {
final Status status = locationSettingsResult.getStatus();
switch (status.getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
getLastKnowLocation();
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
try {
// Show the dialog by calling startResolutionForResult(),
// and check the result in onActivityResult().
status.startResolutionForResult(MapsActivity.this,
REQUEST_CHECK_SETTINGS);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
Log.e(TAG, "Error happen during show Dialog for Turn of GPS");
break;
}
}
});
代码示例来源:origin: Michenux/YourAppIdea
public void onResult(Status status) {
if (status.isSuccess()) {
// Successfully registered
} else if (status.hasResolution()) {
// Google provides a way to fix the issue
try {
status.startResolutionForResult(
AroundMeFragment.this.getActivity(), // your current activity used to receive the result
LOCATIONSERVICES_RESOLUTION_RESULCODE); // the result code you'll look for in your onActivityResult method to retry registering
} catch (IntentSender.SendIntentException e) {
Log.e(YourApplication.LOG_TAG, "SimpleMapFragment start resolution failure: ", e);
}
} else {
// No recovery. Weep softly or inform the user.
Log.e(YourApplication.LOG_TAG, "SimpleMapFragment registering failed: " + status.getStatusMessage());
}
}
});
代码示例来源:origin: prabhat1707/EasyWayLocation
@Override
public void onResult(@NonNull LocationSettingsResult result1) {
Status status = result1.getStatus();
final LocationSettingsStates states = result1.getLocationSettingsStates();
switch (status.getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
mListener.locationOn();
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
try {
status.startResolutionForResult((Activity) context, LOCATION_SETTING_REQUEST_CODE);
} catch (IntentSender.SendIntentException e) {
}
break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
locationReturn = false;
break;
}
}
});
代码示例来源:origin: jakehilborn/speedr
@Override
public void onResult(@NonNull LocationSettingsResult result) {
boolean showingLocationSettingsDialog = false;
if (result.getStatus().getStatusCode() == LocationSettingsStatusCodes.RESOLUTION_REQUIRED) {
try {
//Show location settings change dialog and check the result in onActivityResult()
result.getStatus().startResolutionForResult(MainActivity.this, REQUEST_LOCATION);
showingLocationSettingsDialog = true;
Crashlytics.log(Log.INFO, MainActivity.class.getSimpleName(), "Showing PlayServices GPS settings dialog");
} catch (Exception e) {
Crashlytics.log(Log.ERROR, MainActivity.class.getSimpleName(), "Error showing PlayServices GPS settings dialog");
Crashlytics.logException(e);
}
}
if (!showingLocationSettingsDialog) {
showNoGPSAlert(); //Ask user to manually enable GPS
googleApiClient.disconnect();
}
}
});
代码示例来源:origin: Michenux/YourAppIdea
@SuppressWarnings({"MissingPermission"})
private void registerLocationUpdates() {
PendingResult<Status> result = LocationServices.FusedLocationApi
.requestLocationUpdates(
mGoogleApiClient,
mRequest,
this);
result.setResultCallback(status -> {
if (status.isSuccess()) {
// Successfully registered
} else if (status.hasResolution()) {
// Google provides a way to fix the issue
try {
status.startResolutionForResult(
SimpleMapFragment.this.getActivity(), // your current activity used to receive the result
LOCATIONSERVICES_RESOLUTION_RESULCODE); // the result code you'll look for in your onActivityResult method to retry registering
} catch (IntentSender.SendIntentException e) {
Log.e(YourApplication.LOG_TAG, "SimpleMapFragment start resolution failure: ", e);
}
} else {
// No recovery. Weep softly or inform the user.
Log.e(YourApplication.LOG_TAG, "SimpleMapFragment registering failed: " + status.getStatusMessage());
}
});
}
代码示例来源:origin: nglauber/dominando_android2
@Override
public void onResult(LocationSettingsResult locationSettingsResult) {
final Status status = locationSettingsResult.getStatus();
switch (status.getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
obterUltimaLocalizacao();
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
if (mDeveExibirDialog) {
try {
status.startResolutionForResult(MainActivity.this, REQUEST_CHECAR_GPS);
mDeveExibirDialog = false;
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
}
break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
Log.wtf("NGVL", "Isso não deveria acontecer...");
break;
}
}
});
代码示例来源:origin: dsolonenko/financisto
@Subscribe(threadMode = ThreadMode.MAIN)
public void onDriveBackupFailed(DriveBackupFailure event) {
dismissProgressDialog();
Status status = event.status;
if (status.hasResolution()) {
try {
status.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE);
} catch (IntentSender.SendIntentException e) {
// Unable to resolve, message user appropriately
onDriveBackupError(new DriveBackupError(e.getMessage()));
}
} else {
GooglePlayServicesUtil.getErrorDialog(status.getStatusCode(), this, 0).show();
}
}
内容来源于网络,如有侵权,请联系作者删除!