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


Java GoogleApiAvailability類代碼示例

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


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

示例1: startCameraSource

import com.google.android.gms.common.GoogleApiAvailability; //導入依賴的package包/類
/**
 * Starts or restarts the camera source, if it exists.  If the camera source doesn't exist yet
 * (e.g., because onResume was called before the camera source was created), this will be called
 * again when the camera source is created.
 */
private void startCameraSource() throws SecurityException {
    // check that the device has play services available.
    int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
            getApplicationContext());
    if (code != ConnectionResult.SUCCESS) {
        Dialog dlg =
                GoogleApiAvailability.getInstance().getErrorDialog(this, code, RC_HANDLE_GMS);
        dlg.show();
    }

    if (mCameraSource != null) {
        try {
            mPreview.start(mCameraSource, mGraphicOverlay);
        } catch (IOException e) {
            Log.e(TAG, "Unable to start camera source.", e);
            mCameraSource.release();
            mCameraSource = null;
        }
    }
}
 
開發者ID:OlayinkaPeter,項目名稱:Toodoo,代碼行數:26,代碼來源:ToodooCamera.java

示例2: onResume

import com.google.android.gms.common.GoogleApiAvailability; //導入依賴的package包/類
@Override
public void onResume() {
    super.onResume();
    updateUI();
    
    //checking if Play Store app installed on device
    GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
    int errorCode = apiAvailability.isGooglePlayServicesAvailable(getActivity());

    if (errorCode != ConnectionResult.SUCCESS) {
        Dialog errorDialog = apiAvailability
                .getErrorDialog(getActivity(), errorCode, REQUEST_ERROR,
                        new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {
                        getActivity().finish();
                    }
                });
        errorDialog.show();
    }
}
 
開發者ID:plweegie,項目名稱:piast-trail,代碼行數:22,代碼來源:PlaceListFragment.java

示例3: startCameraSource

import com.google.android.gms.common.GoogleApiAvailability; //導入依賴的package包/類
/**
 * Starts or restarts the camera source, if it exists.  If the camera source doesn't exist yet
 * (e.g., because onResume was called before the camera source was created), this will be called
 * again when the camera source is created.
 */
private void startCameraSource() throws SecurityException {
    // check that the device has play services available.
    int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
            getApplicationContext());
    if (code != ConnectionResult.SUCCESS) {
        Dialog dlg =
                GoogleApiAvailability.getInstance().getErrorDialog(this, code, RC_HANDLE_GMS);
        dlg.show();
    }

    if (mCameraSource != null) {
        try {
            mPreview.start(mCameraSource, mGraphicOverlay);
        } catch (IOException e) {
            mCameraSource.release();
            mCameraSource = null;
        }
    }
}
 
開發者ID:victoraldir,項目名稱:BuddyBook,代碼行數:25,代碼來源:BarcodeCaptureActivity.java

示例4: onResume

import com.google.android.gms.common.GoogleApiAvailability; //導入依賴的package包/類
@Override
protected void onResume() {
    super.onResume();
    
    //checking if Play Store app installed on device
    GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
    int errorCode = apiAvailability.isGooglePlayServicesAvailable(this);

    if (errorCode != ConnectionResult.SUCCESS) {
        Dialog errorDialog = apiAvailability
                .getErrorDialog(this, errorCode, REQUEST_ERROR,
                        new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {
                        finish();
                    }
                });
        errorDialog.show();
    }
}
 
開發者ID:plweegie,項目名稱:piast-trail,代碼行數:21,代碼來源:PlaceDetailsActivity.java

示例5: checkPlayServices

import com.google.android.gms.common.GoogleApiAvailability; //導入依賴的package包/類
public static boolean checkPlayServices(Activity context) {
    GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
    int resultCode = apiAvailability.isGooglePlayServicesAvailable(context);
    if (resultCode != ConnectionResult.SUCCESS) {
        if (apiAvailability.isUserResolvableError(resultCode)) {
            apiAvailability.getErrorDialog(context, resultCode, 9000).show();
        } else {
            AlertDialog.Builder alert = new AlertDialog.Builder(context);
            alert.setTitle(context.getResources().getString(R.string.app_name));
            alert.setCancelable(false);
            alert.setMessage(R.string.play_services_warning);
            alert.setPositiveButton("Exit", (dialog, which) -> System.exit(0));
        }
        return false;
    }
    return true;
}
 
開發者ID:afiqiqmal,項目名稱:My-Android-Base-Code,代碼行數:18,代碼來源:SubUtils.java

示例6: startCameraSource

import com.google.android.gms.common.GoogleApiAvailability; //導入依賴的package包/類
/**
 * Starts or restarts the camera source, if it exists.  If the camera source doesn't exist yet
 * (e.g., because onResume was called before the camera source was created), this will be called
 * again when the camera source is created.
 */
private void startCameraSource() {

    // check that the device has play services available.
    int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
            getApplicationContext());
    if (code != ConnectionResult.SUCCESS) {
        Dialog dlg =
                GoogleApiAvailability.getInstance().getErrorDialog(this, code, RC_HANDLE_GMS);
        dlg.show();
    }

    if (mCameraSource != null) {
        try {
            mPreview.start(mCameraSource, mGraphicOverlay);
        } catch (IOException e) {
            Log.e(TAG, "Unable to start camera source.", e);
            mCameraSource.release();
            mCameraSource = null;
        }
    }
}
 
開發者ID:gsrathoreniks,項目名稱:FaceFilter,代碼行數:27,代碼來源:FaceFilterActivity.java

示例7: showGooglePlayServicesAvailabilityErrorDialog

import com.google.android.gms.common.GoogleApiAvailability; //導入依賴的package包/類
/**
 * Display an error dialog showing that Google Play Services is missing
 * or out of date.
 *
 * @param connectionStatusCode code describing the presence (or lack of)
 *                             Google Play Services on this device.
 */
void showGooglePlayServicesAvailabilityErrorDialog(
        final int connectionStatusCode) {
    if (mProgress != null && mProgress.isShowing()) {
        mProgress.dismiss();
    }

    try {
        GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
        Dialog dialog = apiAvailability.getErrorDialog(
                getActivity(),
                connectionStatusCode,
                ConstantValues.REQUEST_GOOGLE_PLAY_SERVICES);
        dialog.show();
    } catch (Exception e) {
        Utils.showNotReportableErrorDialog(getActivity(), e.getMessage(), "");
    }
}
 
開發者ID:mkeresztes,項目名稱:AndiCar,代碼行數:25,代碼來源:PreferenceActivity.java

示例8: startCameraSource

import com.google.android.gms.common.GoogleApiAvailability; //導入依賴的package包/類
/**
 * Starts or restarts the camera source, if it exists.  If the camera source doesn't exist yet
 * (e.g., because onResume was called before the camera source was created), this will be called
 * again when the camera source is created.
 */
private void startCameraSource() throws SecurityException {
    // Check that the device has play services available.
    int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
            getApplicationContext());
    if (code != ConnectionResult.SUCCESS) {
        Dialog dlg =
                GoogleApiAvailability.getInstance().getErrorDialog(this, code, RC_HANDLE_GMS);
        dlg.show();
    }

    if (mCameraSource != null) {
        try {
            mPreview.start(mCameraSource, mGraphicOverlay);
        } catch (IOException e) {
            Log.e(TAG, "Unable to start camera source.", e);
            mCameraSource.release();
            mCameraSource = null;
        }
    }
}
 
開發者ID:DevipriyaSarkar,項目名稱:OCR-Reader,代碼行數:26,代碼來源:OcrCaptureActivity.java

示例9: checkPlayServices

import com.google.android.gms.common.GoogleApiAvailability; //導入依賴的package包/類
public static boolean checkPlayServices(Activity context) {
    GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
    int resultCode = apiAvailability.isGooglePlayServicesAvailable(context);
    if (resultCode != ConnectionResult.SUCCESS) {
        if (apiAvailability.isUserResolvableError(resultCode)) {
            apiAvailability.getErrorDialog(context, resultCode, 9000).show();
        } else {
            AlertDialog.Builder alert = new AlertDialog.Builder(context);
            alert.setTitle("");
            alert.setMessage("");
            alert.setPositiveButton("EXIT", (dialog, which) -> System.exit(0));
        }
        return false;
    }
    return true;
}
 
開發者ID:afiqiqmal,項目名稱:MVP-Android,代碼行數:17,代碼來源:SubUtils.java

示例10: onConnectionFailed

import com.google.android.gms.common.GoogleApiAvailability; //導入依賴的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

示例11: checkPlayServices

import com.google.android.gms.common.GoogleApiAvailability; //導入依賴的package包/類
/**
 * Check the device to make sure it has the Google Play Services APK. If
 * it doesn't, display a dialog that allows users to download the APK from
 * the Google Play Store or enable it in the device's system settings.
 */
private boolean checkPlayServices() {
    GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
    int resultCode = apiAvailability.isGooglePlayServicesAvailable(cordova.getActivity());
    if (resultCode != ConnectionResult.SUCCESS) {
        if (apiAvailability.isUserResolvableError(resultCode)) {
            apiAvailability.getErrorDialog(cordova.getActivity(), resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
                    .show();
        } else {
            Log.e(TAG, "This device is not supported for Google Play Services.");
            javascriptErrorback(0, "This device is not supported for Google Play Services.", mInitCallbackContext);

        }
        return false;
    }
    return true;
}
 
開發者ID:jefflinwood,項目名稱:twilio-voice-phonegap-plugin,代碼行數:22,代碼來源:TwilioVoicePlugin.java

示例12: checkPlayServices

import com.google.android.gms.common.GoogleApiAvailability; //導入依賴的package包/類
/**
 * Check the device to make sure it has the Google Play Services APK. If
 * it doesn't, display a dialog that allows users to download the APK from
 * the Google Play Store or enable it in the device's system settings.
 */
private boolean checkPlayServices() {
    GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
    int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
    if (resultCode != ConnectionResult.SUCCESS) {
        if (apiAvailability.isUserResolvableError(resultCode)) {
            apiAvailability.getErrorDialog(this, resultCode,
                    PLAY_SERVICES_RESOLUTION_REQUEST).show();
        } else {
            Log.i(LOG_TAG, "This device is not supported.");
            finish();
        }
        return false;
    }
    return true;
}
 
開發者ID:changja88,項目名稱:Udacity_Sunshine,代碼行數:21,代碼來源:MainActivity.java

示例13: LocationEditTextPreference

import com.google.android.gms.common.GoogleApiAvailability; //導入依賴的package包/類
public LocationEditTextPreference(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.getTheme().obtainStyledAttributes(
            attrs,
            R.styleable.LocationEditTextPreference,
            0, 0);
    try {
        mMinLength = a.getInteger(R.styleable.LocationEditTextPreference_minLength, DEFAULT_MINIMUM_LOCATION_LENGTH);
    } finally {
        a.recycle();
    }

    // Check to see if Google Play services is available. The Place Picker API is available
    // through Google Play services, so if this is false, we'll just carry on as though this
    // feature does not exist. If it is true, however, we can add a widget to our preference.
    GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
    int resultCode = apiAvailability.isGooglePlayServicesAvailable(getContext());
    if (resultCode == ConnectionResult.SUCCESS) {
        // Add the get current location widget to our location preference
        setWidgetLayoutResource(R.layout.pref_current_location);
    }
}
 
開發者ID:changja88,項目名稱:Udacity_Sunshine,代碼行數:23,代碼來源:LocationEditTextPreference.java

示例14: handle

import com.google.android.gms.common.GoogleApiAvailability; //導入依賴的package包/類
/**
 * Displays the dialog in a modal manner using
 * {@link GoogleApiAvailability#getErrorDialog(Activity, int, int)}.
 * @param context the context in which the error was encountered
 * @param errorCode the error code from Google Play Services
 */
@Override
protected final void handle(final Context context, final int errorCode) {
    // Assume old dialogs generated by the same error handler are obsolete when an error
    // with a different error code is encountered.
    if (mErrorCode != errorCode) {
        cancelDialog();
    }
    if (mDialog == null) {
        mDialog = GoogleApiAvailability.getInstance().getErrorDialog(
                mActivity, errorCode, NO_RESPONSE_REQUIRED);
        mErrorCode = errorCode;
    }
    // This can happen if |errorCode| is ConnectionResult.SERVICE_INVALID.
    if (mDialog != null) {
        mDialog.show();
    }
    sErrorHandlerActionHistogramSample.record(ERROR_HANDLER_ACTION_MODAL_DIALOG);
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:25,代碼來源:UserRecoverableErrorHandler.java

示例15: onResume

import com.google.android.gms.common.GoogleApiAvailability; //導入依賴的package包/類
@Override
public void onResume() {
    super.onResume();

    GoogleApiAvailability apiAvailablity = GoogleApiAvailability.getInstance();
    int errorCode = apiAvailablity.isGooglePlayServicesAvailable(getContext());

    if (errorCode != ConnectionResult.SUCCESS) {
        Dialog errorDialog = apiAvailablity.getErrorDialog(getActivity(), errorCode,
                REQUEST_ERROR, new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {
                        getActivity().finish();
                    }
                });
        errorDialog.show();
    }
}
 
開發者ID:ivicel,項目名稱:Android-Programming-BigNerd,代碼行數:19,代碼來源:LocatrFragment.java


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