本文整理汇总了Java中com.google.android.gms.common.api.Status.startResolutionForResult方法的典型用法代码示例。如果您正苦于以下问题:Java Status.startResolutionForResult方法的具体用法?Java Status.startResolutionForResult怎么用?Java Status.startResolutionForResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.common.api.Status
的用法示例。
在下文中一共展示了Status.startResolutionForResult方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onResult
import com.google.android.gms.common.api.Status; //导入方法依赖的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;
}
}
示例2: handleLocationStatusResult
import com.google.android.gms.common.api.Status; //导入方法依赖的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());
}
}
示例3: onResult
import com.google.android.gms.common.api.Status; //导入方法依赖的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;
}
}
示例4: handleIntent
import com.google.android.gms.common.api.Status; //导入方法依赖的package包/类
void handleIntent() {
Status status = getIntent().getParcelableExtra(ARG_STATUS);
try {
status.startResolutionForResult(this, REQUEST_CODE_RESOLUTION);
} catch (IntentSender.SendIntentException | NullPointerException e) {
setResolutionResultAndFinish(Activity.RESULT_CANCELED);
}
}
示例5: getLocationSettingsResultCallback
import com.google.android.gms.common.api.Status; //导入方法依赖的package包/类
@NonNull
private ResultCallback<Result> getLocationSettingsResultCallback() {
return new ResultCallback<Result>() {
@Override
public void onResult(@NonNull Result result) {
Status status = result.getStatus();
if (status.getStatusCode() == CommonStatusCodes.SUCCESS) {
Log.i(TAG, "All location settings are satisfied.");
Runnable requestUpdatesTask = new OnPermissionsTask();
if (isConnected()) requestUpdatesTask.run();
else {
mOnConnectedUpdateCallback = requestUpdatesTask;
Log.d(TAG, "Google API is not connected. "
+ "Updates delayed until Google API is connected again.");
}
} else if (status.getStatusCode() == CommonStatusCodes.RESOLUTION_REQUIRED) {
Log.i(TAG, "Location settings are not satisfied. "
+ "Showing the user a dialog to upgrade location settings.");
try {
setRequestingPermissions(true);
// Show the dialog by calling startResolutionForResult(),
// and check the result in the onActivityResult() of mContext
status.startResolutionForResult(mContext, REQUEST_CHECK_SETTINGS);
} catch (IntentSender.SendIntentException e) {
Log.wtf(TAG, "PendingIntent unable to execute request", e);
}
} else if (status.getStatusCode()
== LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE) {
if (checkNetwork()) {
Log.w(TAG, "Location settings can't be changed to meet the requirements");
setHasPermissions(false);
mOnPermissionsChangedListeners.run();
setRequestingPermissions(false);
}
}
}
};
}
示例6: showLocationsSettingsDialog
import com.google.android.gms.common.api.Status; //导入方法依赖的package包/类
@Override
public void showLocationsSettingsDialog(Status status) {
try {
status.startResolutionForResult(this, REQUEST_CHECK_LOCATION_SETTINGS);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
}