本文整理汇总了Java中com.google.android.gms.common.ConnectionResult.hasResolution方法的典型用法代码示例。如果您正苦于以下问题:Java ConnectionResult.hasResolution方法的具体用法?Java ConnectionResult.hasResolution怎么用?Java ConnectionResult.hasResolution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.common.ConnectionResult
的用法示例。
在下文中一共展示了ConnectionResult.hasResolution方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onConnectionFailed
import com.google.android.gms.common.ConnectionResult; //导入方法依赖的package包/类
@Override
public void onConnectionFailed(@NonNull ConnectionResult m_result) {
Utils.d("Google:Connection:Failed");
if (isResolvingConnectionFailure) { return; }
if(!isIntentInProgress && m_result.hasResolution()) {
try {
isIntentInProgress = true;
activity.startIntentSenderForResult(
m_result.getResolution().getIntentSender(),
Utils.FIREBASE_GOOGLE_SIGN_IN, null, 0, 0, 0);
} catch (SendIntentException ex) {
isIntentInProgress = false;
signIn();
}
isResolvingConnectionFailure = true;
Utils.d("Google:Connection:Resolving.");
}
}
示例2: onConnectionFailed
import com.google.android.gms.common.ConnectionResult; //导入方法依赖的package包/类
@Override
public void onConnectionFailed( @NonNull ConnectionResult connectionResult ) {
AIR.log( "GameServicesHelper | connection FAILED" );
AIR.log( "Error message: " + connectionResult.getErrorMessage() );
AIR.log( "Error code: " + connectionResult.getErrorCode() );
if( !connectionResult.isSuccess() && connectionResult.hasResolution() ) {
if( mPendingAchievementsUI ) {
AIR.log( "GameServicesHelper | failed to connect with Google client, resolution available" );
mPendingAchievementsUI = false;
resolvePendingAchievementsUIError( connectionResult );
}
/* Start resolution intent only if the user requested auth himself */
else if( mUserAuth ) {
AIR.log( "GameServicesHelper | failed to connect with Google client, resolution available" );
resolveSignInConnectionResult( connectionResult );
} else {
AIR.log( "GameServicesHelper | not starting auth resolution intent because user has not made the auth request himself" );
mPendingConnectionResult = connectionResult;
}
} else {
AIR.log( "GameServicesHelper | failed to connect with Google client, no resolution" );
}
}
示例3: resolveConnectionFailure
import com.google.android.gms.common.ConnectionResult; //导入方法依赖的package包/类
/**
* Resolve a connection failure from
* {@link com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener#onConnectionFailed(com.google.android.gms.common.ConnectionResult)}
*
* @param activity the Activity trying to resolve the connection failure.
* @param client the GoogleAPIClient instance of the Activity.
* @param result the ConnectionResult received by the Activity.
* @param requestCode a request code which the calling Activity can use to identify the result
* of this resolution in onActivityResult.
* @param fallbackErrorMessage a generic error message to display if the failure cannot be resolved.
* @return true if the connection failure is resolved, false otherwise.
*/
public static boolean resolveConnectionFailure(Activity activity,
GoogleApiClient client, ConnectionResult result, int requestCode,
int fallbackErrorMessage) {
if (result.hasResolution()) {
try {
result.startResolutionForResult(activity, requestCode);
return true;
} catch (IntentSender.SendIntentException e) {
// The intent was canceled before it was sent. Return to the default
// state and attempt to connect to get an updated ConnectionResult.
client.connect();
return false;
}
} else {
// not resolvable... so show an error message
int errorCode = result.getErrorCode();
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
activity, requestCode);
if (dialog != null) {
dialog.show();
} else {
// no built-in dialog: show the fallback error message
showAlert(activity, activity.getString(fallbackErrorMessage));
}
return false;
}
}
示例4: onConnectionFailed
import com.google.android.gms.common.ConnectionResult; //导入方法依赖的package包/类
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
if (!isResolving && shouldResolve) {
if (connectionResult.hasResolution()) {
try {
connectionResult.startResolutionForResult(fragment.getActivity(), RC_SIGN_IN);
isResolving = true;
} catch (IntentSender.SendIntentException e) {
isResolving = false;
googleApiClient.connect();
}
} else {
showErrorDialog(connectionResult);
}
}
}
示例5: onConnectionFailed
import com.google.android.gms.common.ConnectionResult; //导入方法依赖的package包/类
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
if (mResolvingConnectionError) {
return;
} else if (connectionResult.hasResolution()) {
try {
mResolvingConnectionError = true;
connectionResult.startResolutionForResult(this, REQUEST_RESOLVE_CONNECTION_ERROR);
} catch (IntentSender.SendIntentException e) {
// There was an error with the resolution intent. Try again.
mGoogleApiClient.connect();
}
} else {
// Show dialog using GoogleApiAvailability.getErrorDialog()
showErrorDialog(connectionResult.getErrorCode());
mResolvingConnectionError = true;
}
}
示例6: onConnectionFailed
import com.google.android.gms.common.ConnectionResult; //导入方法依赖的package包/类
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Toast.makeText(this, "onConnectionFailed:" + connectionResult.getErrorMessage(), Toast.LENGTH_SHORT).show();
// Viene chiamata nel caso la connect fallisca ad esempio
// non è ancora stata data autorizzaiozne alla applicazione corrente
if (connectionResult.hasResolution()) {
try {
connectionResult.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE);
} catch (IntentSender.SendIntentException e) {
// Unable to resolve, message user appropriately
}
} else {
GoogleApiAvailability.getInstance().getErrorDialog(this, connectionResult.getErrorCode(), 0).show();
}
}
示例7: onConnectionFailed
import com.google.android.gms.common.ConnectionResult; //导入方法依赖的package包/类
public void onConnectionFailed(ConnectionResult connectionResult) {
/*
* Google Play services can resolve some errors it detects.
* If the error has a resolution, try sending an Intent to
* start a Google Play services activity that can resolve
* error.
*/
if (connectionResult.hasResolution()) {
try {
// Start an Activity that tries to resolve the error
connectionResult.startResolutionForResult(
this,
ValueHelper.CONNECTION_FAILURE_RESOLUTION_REQUEST);
/*
* Thrown if Google Play services canceled the original
* PendingIntent
*/
} catch (IntentSender.SendIntentException e) {
// Log the error
e.printStackTrace();
}
}
}
示例8: onConnectionFailed
import com.google.android.gms.common.ConnectionResult; //导入方法依赖的package包/类
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
// Called whenever the API client fails to connect.
Log.i(TAG, "GoogleApiClient connection failed: " + connectionResult.toString());
if (!connectionResult.hasResolution()) {
// show the localized error dialog.
GoogleApiAvailability.getInstance().getErrorDialog(activity, connectionResult.getErrorCode(), 0).show();
return;
}
// The failure has a resolution. Resolve it.
// Called typically when the app is not yet authorized, and an
// authorization
// dialog is displayed to the user.
try {
connectionResult.startResolutionForResult(activity, CONNECTION_FAILED_POPUP);
} catch (IntentSender.SendIntentException e) {
Log.e(TAG, "Exception while starting resolution activity", e);
}
}
示例9: onConnectionFailed
import com.google.android.gms.common.ConnectionResult; //导入方法依赖的package包/类
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
DebugLog.logMethod();
DebugLog.logMessage("ConnectionResult: " + connectionResult.toString());
DebugLog.logMessage("ConnectionResult error: " + connectionResult.getErrorCode() + "\n" + connectionResult.getErrorMessage());
if (!connectionResult.hasResolution()) {
GoogleApiAvailability.getInstance()
.getErrorDialog(getActivity(), connectionResult.getErrorCode(), 0)
.show();
return;
}
try {
connectionResult.startResolutionForResult(getActivity(), Constants.CONNECTION_RESOLUTION_REQUEST_CODE);
connectionFailed = true;
} catch (IntentSender.SendIntentException e) {
// Unable to resolve, message user appropriately
e.printStackTrace();
DebugLog.logMessage(e.getMessage());
Utilities.showToast(getActivity(), getString(R.string.google_drive_no_resolution));
}
}
示例10: onConnectionFailed
import com.google.android.gms.common.ConnectionResult; //导入方法依赖的package包/类
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
if (connectionResult.hasResolution()) {
try {
connectionResult.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE);
} catch (IntentSender.SendIntentException e) {
Toast.makeText(getApplicationContext(), getString(R.string.drive_fail_connect), Toast.LENGTH_LONG).show();
}
}
}
示例11: onConnectionFailed
import com.google.android.gms.common.ConnectionResult; //导入方法依赖的package包/类
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
// Could not connect to Google Play Services. The user needs to select an account,
// grant permissions or resolve an error in order to sign in. Refer to the javadoc for
// ConnectionResult to see possible error codes.
Log.d(Constants.TAG_LOGIN, "onConnectionFailed:" + connectionResult);
ringProgressDialog.dismiss();
if (!mIsResolving && mShouldResolve) {
if (connectionResult.hasResolution()) {
try {
connectionResult.startResolutionForResult(this, RC_SIGN_IN);
mIsResolving = true;
} catch (IntentSender.SendIntentException e) {
Log.e(Constants.TAG_LOGIN, "Could not resolve ConnectionResult.", e);
Toast.makeText(LoginActivity.this, "Could not resolve ConnectionResult", Toast.LENGTH_LONG).show();
mIsResolving = false;
}
} else {
// Could not resolve the connection result, show the user an
// error dialog.
Toast.makeText(LoginActivity.this, "Error on Login, check your google + login method", Toast.LENGTH_LONG).show();
}
} else {
// Show the signed-out UI
}
}
示例12: onConnectionFailed
import com.google.android.gms.common.ConnectionResult; //导入方法依赖的package包/类
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
if (connectionResult.hasResolution()) {
try {
connectionResult.startResolutionForResult(this, REQUEST_CODE_RESOLVE_CONNECTION);
} catch (IntentSender.SendIntentException e) {
// Unable to resolve, message user appropriately
}
} else {
GooglePlayServicesUtil.getErrorDialog(connectionResult.getErrorCode(), this, 0).show();
}
}
示例13: resolveConnectionFailure
import com.google.android.gms.common.ConnectionResult; //导入方法依赖的package包/类
/**
* Resolve a connection failure from
* {@link com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener#onConnectionFailed(com.google.android.gms.common.ConnectionResult)}
*
* @param activity the Activity trying to resolve the connection failure.
* @param client the GoogleAPIClient instance of the Activity.
* @param result the ConnectionResult received by the Activity.
* @param requestCode a request code which the calling Activity can use to identify the result
* of this resolution in onActivityResult.
* @param fallbackErrorMessage a generic error message to display if the failure cannot be resolved.
* @return true if the connection failure is resolved, false otherwise.
*/
public static boolean resolveConnectionFailure(Activity activity,
GoogleApiClient client, ConnectionResult result, int requestCode,
String fallbackErrorMessage) {
if (result.hasResolution()) {
try {
result.startResolutionForResult(activity, requestCode);
return true;
} catch (IntentSender.SendIntentException e) {
// The intent was canceled before it was sent. Return to the default
// state and attempt to connect to get an updated ConnectionResult.
client.connect();
return false;
}
} else {
// not resolvable... so show an error message
int errorCode = result.getErrorCode();
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
activity, requestCode);
if (dialog != null) {
dialog.show();
} else {
// no built-in dialog: show the fallback error message
showAlert(activity, fallbackErrorMessage);
}
return false;
}
}
示例14: onConnectionFailed
import com.google.android.gms.common.ConnectionResult; //导入方法依赖的package包/类
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
if (connectionResult.hasResolution()) {
try {
connectionResult.startResolutionForResult(mContext, CONNECTION_FAILURE_RESOLUTION);
} catch (IntentSender.SendIntentException e) {
Log.wtf(TAG, "Location services connection failed.", e);
}
} else {
Log.wtf(TAG, "Location services connection failed with code "
+ connectionResult.getErrorCode());
}
}
示例15: onConnectionFailed
import com.google.android.gms.common.ConnectionResult; //导入方法依赖的package包/类
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
if (connectionResult.hasResolution()) {
try {
// Start an Activity that tries to resolve the error
connectionResult.startResolutionForResult(this, 9000);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
} else {
Log.i("a", "Location services connection failed with code " + connectionResult.getErrorCode());
}
}