当前位置: 首页>>代码示例>>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;未经允许,请勿转载。