Java Code Examples for com.google.android.gms.common.ConnectionResult#startResolutionForResult()
The following examples show how to use
com.google.android.gms.common.ConnectionResult#startResolutionForResult() .
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: Main.java From chess with Apache License 2.0 | 6 votes |
@Override public void onConnectionFailed(final ConnectionResult connectionResult) { if (connectionResult.hasResolution()) { // This problem can be fixed. So let's try to fix it. try { // launch appropriate UI flow (which might, for example, be the // sign-in flow) connectionResult.startResolutionForResult(this, RC_RESOLVE); } catch (IntentSender.SendIntentException e) { // Try connecting again mGoogleApiClient.connect(); } } else { GooglePlayServicesUtil.getErrorDialog(connectionResult.getErrorCode(), this, 0).show(); } }
Example 2
Source File: MainActivity.java From AndroidWearable-Samples with Apache License 2.0 | 6 votes |
@Override //OnConnectionFailedListener public void onConnectionFailed(ConnectionResult result) { if (mResolvingError) { // Already attempting to resolve an error. return; } else if (result.hasResolution()) { try { mResolvingError = true; result.startResolutionForResult(this, REQUEST_RESOLVE_ERROR); } catch (IntentSender.SendIntentException e) { // There was an error with the resolution intent. Try again. mGoogleApiClient.connect(); } } else { Log.e(TAG, "Connection to Google API client has failed"); mResolvingError = false; mStartActivityBtn.setEnabled(false); mSendPhotoBtn.setEnabled(false); Wearable.DataApi.removeListener(mGoogleApiClient, this); Wearable.MessageApi.removeListener(mGoogleApiClient, this); Wearable.NodeApi.removeListener(mGoogleApiClient, this); } }
Example 3
Source File: MainActivity.java From gplus-haiku-client-android with Apache License 2.0 | 6 votes |
@Override public void onConnectionFailed(ConnectionResult connectionResult) { Log.d(TAG, "Connection failed"); if (mIsResolving) { Log.d(TAG, "Already resolving."); return; } // Attempt to resolve the ConnectionResult if (connectionResult.hasResolution() && mSignInClicked) { mIsResolving = true; mSignInClicked = false; try { connectionResult.startResolutionForResult(this, REQ_SIGN_IN); } catch (IntentSender.SendIntentException e) { Log.e(TAG, "Could not resolve.", e); mIsResolving = false; mGoogleApiClient.connect(); } } }
Example 4
Source File: DriveActivity.java From biermacht with Apache License 2.0 | 6 votes |
@Override public void onConnectionFailed(ConnectionResult result) { Log.d("DriveActivity", "Google API Connection failed"); if (result.hasResolution()) { Log.d("DriveActivity", "Failure has a resolution, starting"); try { result.startResolutionForResult(this, Constants.REQUEST_CONNECT_TO_DRIVE); } catch (IntentSender.SendIntentException e) { driveClient.connect(); } } else { Log.e("DriveActivity", "No resolution, showing error dialog"); GoogleApiAvailability.getInstance().getErrorDialog(this, result.getErrorCode(), Constants.REQUEST_CONNECT_TO_DRIVE).show(); } }
Example 5
Source File: MainActivity.java From AndroidWearable-Samples with Apache License 2.0 | 6 votes |
@Override public void onConnectionFailed(ConnectionResult connectionResult) { mInProgress = false; // If the error has a resolution, start a Google Play services activity to resolve it. if (connectionResult.hasResolution()) { try { connectionResult.startResolutionForResult(this, CONNECTION_FAILURE_RESOLUTION_REQUEST); } catch (IntentSender.SendIntentException e) { Log.e(TAG, "Exception while resolving connection error.", e); } } else { int errorCode = connectionResult.getErrorCode(); Log.e(TAG, "Connection to Google Play services failed with error code " + errorCode); } }
Example 6
Source File: WearService.java From LibreAlarm with GNU General Public License v3.0 | 6 votes |
@Override public void onConnectionFailed(ConnectionResult result) { if (mResolvingError) { // Already attempting to resolve an error. return; } else if (result.hasResolution() && mActivity != null) { try { mResolvingError = true; result.startResolutionForResult(mActivity, 1000); } catch (IntentSender.SendIntentException e) { // There was an error with the resolution intent. Try again. mGoogleApiClient.connect(); } } else { Log.e(TAG, "Connection to Google API client has failed"); mResolvingError = false; if (mListener != null) mListener.onDataUpdated(); Wearable.MessageApi.removeListener(mGoogleApiClient, this); Wearable.DataApi.removeListener(mGoogleApiClient, this); } }
Example 7
Source File: MainActivity.java From Android-9-Development-Cookbook with MIT License | 6 votes |
@Override public void onConnectionFailed(ConnectionResult connectionResult) { Toast.makeText(MainActivity.this, connectionResult.toString(), Toast.LENGTH_LONG).show(); if (mResolvingError) { return; } else if (connectionResult.hasResolution()) { mResolvingError = true; try { connectionResult.startResolutionForResult(MainActivity.this, REQUEST_RESOLVE_GOOGLE_CLIENT_ERROR); } catch (IntentSender.SendIntentException e) { mGoogleApiClient.connect(); } } else { showGoogleAPIErrorDialog(connectionResult.getErrorCode()); } }
Example 8
Source File: MainActivity.java From WheelLogAndroid with GNU General Public License v3.0 | 6 votes |
@Override public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { Timber.i("GoogleApiClient connection failed: %s", connectionResult.toString()); if (!connectionResult.hasResolution()) { // show the localized error dialog. GoogleApiAvailability.getInstance().getErrorDialog(this, connectionResult.getErrorCode(), 0).show(); SettingsUtil.setAutoUploadEnabled(this, false); ((PreferencesFragment) getPreferencesFragment()).refreshVolatileSettings(); return; } try { connectionResult.startResolutionForResult(this, REQUEST_CODE_RESOLUTION); } catch (IntentSender.SendIntentException e) { Timber.e("Exception while starting resolution activity"); } }
Example 9
Source File: MainActivity.java From effective_android_sample with Apache License 2.0 | 6 votes |
@Override public void onConnectionFailed(ConnectionResult connectionResult) { mInProgress = false; /* * Google Play services が問題解決できる場合、Google Play servicesを 呼び出して、解決を要求する。 */ if (connectionResult.hasResolution()) { try { connectionResult.startResolutionForResult(this, CONNECTION_FAILURE_RESOLUTION_REQUEST); } catch (IntentSender.SendIntentException e) { e.printStackTrace(); } } else { // エラーダイアログ表示 showErrorDialog(connectionResult.getErrorCode()); } }
Example 10
Source File: GooglePlayServices.java From JayPS-AndroidApp with MIT License | 5 votes |
@Override public void startConnectionResultResolution(ConnectionResult result, Activity activity) throws IntentSender.SendIntentException{ try { result.startResolutionForResult(activity, REQUEST_OAUTH); }catch (IntentSender.SendIntentException e) { throw e; } }
Example 11
Source File: GooglePlay.java From ExtensionsPack with MIT License | 5 votes |
public void onConnectionFailed(ConnectionResult result) { try { GooglePlay.result = result.getErrorCode(); if(GooglePlay.result == ConnectionResult.SIGN_IN_REQUIRED) { Log.i("trace", what + ": GooglePlayCallback: SignIn Required"); if(what == "GAMES_CLIENT") { result.startResolutionForResult(GameActivity.getInstance(), GooglePlay.GOOGLE_PLAY_SIGN_IN_REQUEST); } else if(what == "APP_STATE_CLIENT") { result.startResolutionForResult(GameActivity.getInstance(), GooglePlay.GOOGLE_PLAY_APP_STATE_SIGN_IN_REQUEST); } } else { Log.i("trace", what + ": GooglePlayCallback.onConnectionFailed: " + GooglePlay.result); } } catch(Exception e) { Log.i("trace", what + ": GooglePlayCallback.onConnectionFailed: " + e.toString()); if(GooglePlay.connectionCallback != null) { GooglePlay.connectionCallback.call("onException", new Object[] {e.toString(), "onConnectionFailed"}); } } }
Example 12
Source File: GooglePlayClientWrapper.java From barterli_android with Apache License 2.0 | 5 votes |
@Override public void onConnectionFailed(final ConnectionResult connectionResult) { mConnectionResult = 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(mActivity, CONNECTION_FAILURE_RESOLUTION_REQUEST); /* * Thrown if Google Play services canceled the original * PendingIntent */ } catch (final IntentSender.SendIntentException e) { //Logger the error e.printStackTrace(); } } else { /* * If no resolution is available, display a dialog to the user with * the error. */ // showErrorDialog(connectionResult.getErrorCode()); final Dialog errorDialog = GooglePlayServicesUtil .getErrorDialog(connectionResult.getErrorCode(), mActivity, CONNECTION_FAILURE_RESOLUTION_REQUEST); // If Google Play services can provide an error dialog if (errorDialog != null) { // Create a new DialogFragment for the error dialog final ErrorDialogFragment errorFragment = new ErrorDialogFragment(); // Set the dialog in the DialogFragment errorFragment.setDialog(errorDialog); // Show the error dialog in the DialogFragment errorFragment.show(mActivity.getSupportFragmentManager(), "Location Updates"); } } }
Example 13
Source File: MainActivity.java From android-location-service with Apache License 2.0 | 5 votes |
@Override public void onLocationServicesConnectionFailed(ConnectionResult result) { Log.i(TAG, "GoogleApiClient connection failed: " + result.toString()); if (!result.hasResolution()) { mShouldRetryConnecting = true; // Show a localized error dialog. GooglePlayServicesUtil.getErrorDialog( result.getErrorCode(), this, 0, new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { retryConnecting(); } }).show(); return; } // If there is an existing resolution error being displayed or a resolution // activity has started before, do nothing and wait for resolution // progress to be completed. if (mIsInResolution) { return; } mIsInResolution = true; try { result.startResolutionForResult(this, REQUEST_CODE_RESOLUTION); } catch (IntentSender.SendIntentException e) { Log.e(TAG, "Exception while starting resolution activity", e); retryConnecting(); } }
Example 14
Source File: MapsActivity.java From android-location-example with MIT License | 5 votes |
@Override 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, CONNECTION_FAILURE_RESOLUTION_REQUEST); /* * Thrown if Google Play services canceled the original * PendingIntent */ } catch (IntentSender.SendIntentException e) { // Log the error e.printStackTrace(); } } else { /* * If no resolution is available, display a dialog to the * user with the error. */ Log.i(TAG, "Location services connection failed with code " + connectionResult.getErrorCode()); } }
Example 15
Source File: CompanionActivity.java From robocar with Apache License 2.0 | 5 votes |
@Override public void onGoogleApiConnectionFailed(ConnectionResult connectionResult) { if (connectionResult.hasResolution()) { try { connectionResult.startResolutionForResult(this, REQUEST_RESOLVE_CONNECTION); } catch (SendIntentException e) { Log.e(TAG, "Google API connection failed. " + connectionResult, e); } } else { Log.e(TAG, "Google API connection failed. " + connectionResult); } }
Example 16
Source File: TheHubActivity.java From ToDay with MIT License | 5 votes |
@Override public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { /* Callback can be invoked if user has not previously authorized the app. */ if (connectionResult.hasResolution()) { try { connectionResult.startResolutionForResult(this, AppConstants.EXPORT_RESOLVE_CONNECTION_REQUEST_CODE); } catch (IntentSender.SendIntentException e) { // Unable to resolve, message user appropriately } } else { Toast.makeText(this, R.string.feedback_failed_msg, Toast.LENGTH_LONG).show(); GooglePlayServicesUtil.getErrorDialog(connectionResult.getErrorCode(), this, 0).show(); } }
Example 17
Source File: MainActivity.java From effective_android_sample with Apache License 2.0 | 5 votes |
@Override public void onConnectionFailed(ConnectionResult connectionResult) { Log.d(TAG, "onConnectionFailed"); /* * Google Play servicesに接続できなかった場合でも、解決策が提示される場合があります。 インテントを投げるとよしなに解決してくれます。 */ if (connectionResult.hasResolution()) { try { // エラーを解決してくれるインテントを投げます connectionResult.startResolutionForResult(this, CONNECTION_FAILURE_RESOLUTION_REQUEST); /* * 失敗することもあります */ } catch (IntentSender.SendIntentException e) { // Log the error e.printStackTrace(); } } else { // 解決策がない場合はエラーダイアログを出します showErrorDialog(connectionResult.getErrorCode(), CONNECTION_FAILURE_RESOLUTION_REQUEST); } }
Example 18
Source File: BaseGameUtils.java From Asteroid with Apache License 2.0 | 5 votes |
/** * 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(AppCompatActivity 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; } }
Example 19
Source File: MainActivity.java From AndroidDemoProjects with Apache License 2.0 | 5 votes |
@Override public void onConnectionFailed(ConnectionResult connectionResult) { if( !authInProgress ) { try { authInProgress = true; connectionResult.startResolutionForResult( MainActivity.this, REQUEST_OAUTH ); } catch(IntentSender.SendIntentException e ) { Log.e( "GoogleFit", "sendingIntentException " + e.getMessage() ); } } else { Log.e( "GoogleFit", "authInProgress" ); } }
Example 20
Source File: SearchClinics.java From Crimson with Apache License 2.0 | 4 votes |
@Override public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { if (connectionResult.hasResolution()) { try { connectionResult.startResolutionForResult(this, CONNECTION_FAILURE_RESOLUTION_REQUEST); } catch (IntentSender.SendIntentException e) { e.printStackTrace(); } } else { Log.e("Error", "Location services connection failed with code " + connectionResult.getErrorCode()); } }