當前位置: 首頁>>代碼示例>>Java>>正文


Java ConnectionResult.startResolutionForResult方法代碼示例

本文整理匯總了Java中com.google.android.gms.common.ConnectionResult.startResolutionForResult方法的典型用法代碼示例。如果您正苦於以下問題:Java ConnectionResult.startResolutionForResult方法的具體用法?Java ConnectionResult.startResolutionForResult怎麽用?Java ConnectionResult.startResolutionForResult使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.android.gms.common.ConnectionResult的用法示例。


在下文中一共展示了ConnectionResult.startResolutionForResult方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onConnectionFailed

import com.google.android.gms.common.ConnectionResult; //導入方法依賴的package包/類
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    if (mProgress != null) {
        mProgress.dismiss();
    }

    secureBkGDriveFolderPreference.setEnabled(false);
    if (connectionResult.hasResolution()) {
        try {
            connectionResult.startResolutionForResult(BackupRestorePreferenceFragment.this.getActivity(), ConstantValues.REQUEST_GDRIVE_AUTHORIZATION);
        } catch (IntentSender.SendIntentException e) {
            // Unable to resolve, message user appropriately
        }
    } else {
        GoogleApiAvailability.getInstance().getErrorDialog(getActivity(), connectionResult.getErrorCode(), 0).show();
    }
}
 
開發者ID:mkeresztes,項目名稱:AndiCar,代碼行數:18,代碼來源:PreferenceActivity.java

示例2: 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);
    }
}
 
開發者ID:SKT-ThingPlug,項目名稱:thingplug-sdk-android,代碼行數:20,代碼來源:GoogleDriveHandler.java

示例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;
    }
}
 
開發者ID:AndreFCruz,項目名稱:feup-lpoo-armadillo,代碼行數:41,代碼來源:BaseGameUtils.java

示例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);
        }
    }
}
 
開發者ID:moldedbits,項目名稱:argus-android,代碼行數:18,代碼來源:GoogleHelper.java

示例5: 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();
        }
    }

}
 
開發者ID:Greenstand,項目名稱:treetracker-android,代碼行數:25,代碼來源:MainActivity.java

示例6: onConnectionFailed

import com.google.android.gms.common.ConnectionResult; //導入方法依賴的package包/類
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    Log.i(TAG, "onConnectionFailed:" + connectionResult.getErrorMessage());

    // 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();
    }
}
 
開發者ID:claudiodegio,項目名稱:dbsync,代碼行數:17,代碼來源:BaseMainDbActivity.java

示例7: 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));
    }
}
 
開發者ID:darsh2,項目名稱:CouponsTracker,代碼行數:23,代碼來源:SettingsFragment.java

示例8: 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;
    }
}
 
開發者ID:Magicrafter13,項目名稱:1946,代碼行數:41,代碼來源:BaseGameUtils.java

示例9: onConnectionFailed

import com.google.android.gms.common.ConnectionResult; //導入方法依賴的package包/類
@Override
public void onConnectionFailed(@NonNull ConnectionResult result) {
    if (!result.hasResolution()) {
        GoogleApiAvailability.getInstance().getErrorDialog(activity, result.getErrorCode(), 0).show();
        return;
    }
    try {
        result.startResolutionForResult(activity, REQUEST_CODE_RESOLUTION);
    } catch (IntentSender.SendIntentException e) {
        uploadFailed();
    }
}
 
開發者ID:apuder,項目名稱:ActivityMonitor,代碼行數:13,代碼來源:DriveUploader.java

示例10: resolveSignInConnectionResult

import com.google.android.gms.common.ConnectionResult; //導入方法依賴的package包/類
/**
 *
 *
 * Private API
 *
 *
 */

private void resolveSignInConnectionResult( @NonNull ConnectionResult connectionResult ) {
	AIR.log( "GameServicesHelper::resolveSignInConnectionResult ErrorCode:" + connectionResult.getErrorCode() );
	mUserAuth = false;
	mPendingConnectionResult = null;

	try {
		connectionResult.startResolutionForResult( AIR.getContext().getActivity(), AUTH_RESULT_CODE );
		AIR.dispatchEvent( GameServicesEvent.WILL_PRESENT_AUTH_DIALOG );
	} catch( IntentSender.SendIntentException e ) {
		e.printStackTrace();
		mGoogleApiClient.connect();
	}
}
 
開發者ID:marpies,項目名稱:game-services-ane,代碼行數:22,代碼來源:GameServicesHelper.java

示例11: 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());
    }

}
 
開發者ID:prabhavgupta,項目名稱:BookED,代碼行數:16,代碼來源:MapsActivity.java

示例12: 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;
    }
}
 
開發者ID:ezet,項目名稱:penguins-in-space,代碼行數:41,代碼來源:BaseGameUtils.java

示例13: resolvePendingAchievementsUIError

import com.google.android.gms.common.ConnectionResult; //導入方法依賴的package包/類
private void resolvePendingAchievementsUIError( @NonNull ConnectionResult connectionResult ) {
	AIR.log( "GameServicesHelper::resolveSignInConnectionResult ErrorCode:" + connectionResult.getErrorCode() );

	try {
		connectionResult.startResolutionForResult( AIR.getContext().getActivity(), AUTH_RESULT_CODE );
	} catch( IntentSender.SendIntentException e ) {
		e.printStackTrace();
		mGoogleApiClient.connect();
	}
}
 
開發者ID:marpies,項目名稱:game-services-ane,代碼行數:11,代碼來源:GameServicesHelper.java

示例14: 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;
    }
}
 
開發者ID:TheAndroidMaster,項目名稱:Asteroid,代碼行數:41,代碼來源:BaseGameUtils.java

示例15: 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();
    }
}
 
開發者ID:mkeresztes,項目名稱:AndiCar,代碼行數:13,代碼來源:TestActivity.java


注:本文中的com.google.android.gms.common.ConnectionResult.startResolutionForResult方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。