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


Java GoogleApiAvailability.getInstance方法代碼示例

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


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

示例1: checkPlayServices

import com.google.android.gms.common.GoogleApiAvailability; //導入方法依賴的package包/類
@SuppressLint("LongLogTag")
private boolean checkPlayServices() {
    GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
    int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
    if (resultCode != ConnectionResult.SUCCESS) {
        if (apiAvailability.isUserResolvableError(resultCode)) {
            apiAvailability.getErrorDialog(this, resultCode, 9000, new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    finish();
                }
            }).show();
        } else {
            Log.i(TAG, "This device is not supported.");
            finish();
        }
        return false;
    }
    return true;
}
 
開發者ID:squareboat,項目名稱:Excuser,代碼行數:21,代碼來源:SplashActivity.java

示例2: 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

示例3: 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.
 */
public static boolean checkPlayServices(AppCompatActivity activity, int PLAY_SERVICES_RESOLUTION_REQUEST) {
    GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
    int resultCode = apiAvailability.isGooglePlayServicesAvailable(activity);
    if (resultCode != ConnectionResult.SUCCESS) {
        if (apiAvailability.isUserResolvableError(resultCode)) {
            apiAvailability.getErrorDialog(activity, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
                    .show();
        } else {
            MaterialDialog dialog = new MaterialDialog.Builder(activity)
                    .content("This device is not supported.")
                    .show();
        }
        return false;
    }
    return true;
}
 
開發者ID:SalmanTKhan,項目名稱:MyAnimeViewer,代碼行數:22,代碼來源:PlayServicesUtils.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包/類
/**
 * 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

示例6: onResume

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

    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 dialogInterface) {
                        // Leave if services are unavailable.
                        finish();
                    }
                });

        errorDialog.show();
    }
}
 
開發者ID:rsippl,項目名稱:AndroidProgramming3e,代碼行數:23,代碼來源:LocatrActivity.java

示例7: 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

示例8: isGooglePlayServicesAvailable

import com.google.android.gms.common.GoogleApiAvailability; //導入方法依賴的package包/類
/**
 * Check that Google Play services APK is installed and up to date.
 * @return true if Google Play Services is available and up to date on this device, false otherwise.
 */
public static boolean isGooglePlayServicesAvailable(Context context) {
    GoogleApiAvailability apiAvailability =
            GoogleApiAvailability.getInstance();

    final int connectionStatusCode =
            apiAvailability.isGooglePlayServicesAvailable(context);
    return connectionStatusCode == ConnectionResult.SUCCESS;
}
 
開發者ID:PrivacyStreams,項目名稱:PrivacyStreams,代碼行數:13,代碼來源:DeviceUtils.java

示例9: acquireGooglePlayServices

import com.google.android.gms.common.GoogleApiAvailability; //導入方法依賴的package包/類
/**
 * Attempt to resolve a missing, out-of-date, invalid or disabled Google
 * Play Services installation via a user dialog, if possible.
 */
public static void acquireGooglePlayServices(Context context) {
    GoogleApiAvailability apiAvailability =
            GoogleApiAvailability.getInstance();
    final int connectionStatusCode =
            apiAvailability.isGooglePlayServicesAvailable(context);
    if (apiAvailability.isUserResolvableError(connectionStatusCode)) {
       Log.e("Error","Connection Status Code"+connectionStatusCode);
    }
}
 
開發者ID:PrivacyStreams,項目名稱:PrivacyStreams,代碼行數:14,代碼來源:DeviceUtils.java

示例10: CheckGooglePlayServices

import com.google.android.gms.common.GoogleApiAvailability; //導入方法依賴的package包/類
private boolean CheckGooglePlayServices() {
    GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
    int result = googleAPI.isGooglePlayServicesAvailable(this);
    if(result != ConnectionResult.SUCCESS) {
        if(googleAPI.isUserResolvableError(result)) {
            googleAPI.getErrorDialog(this, result,
                    0).show();
        }
        return false;
    }
    return true;
}
 
開發者ID:ayushghd,項目名稱:iSPY,代碼行數:13,代碼來源:MapsActivity3.java

示例11: isGooglePlayServicesAvailable

import com.google.android.gms.common.GoogleApiAvailability; //導入方法依賴的package包/類
/**
 * Method to check if google play services are enabled or not
 *
 * @return boolean status
 */
public boolean isGooglePlayServicesAvailable() {
    GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
    int status = googleApiAvailability.isGooglePlayServicesAvailable(this);
    if (status != ConnectionResult.SUCCESS) {
        if (googleApiAvailability.isUserResolvableError(status)) {
            googleApiAvailability.getErrorDialog(this, status, 2404).show();
        }
        return false;
    }
    return true;
}
 
開發者ID:pmathew92,項目名稱:MapsWithPlacesAutoComplete,代碼行數:17,代碼來源:MapsActivity.java

示例12: isGooglePlayServicesAvailable

import com.google.android.gms.common.GoogleApiAvailability; //導入方法依賴的package包/類
/**
 * Check that Google Play services APK is installed and up to date.
 *
 * @return true if Google Play Services is available and up to
 * date on this device; false otherwise.
 */
private boolean isGooglePlayServicesAvailable() {
    GoogleApiAvailability apiAvailability =
            GoogleApiAvailability.getInstance();
    final int connectionStatusCode =
            apiAvailability.isGooglePlayServicesAvailable(context);
    return connectionStatusCode == ConnectionResult.SUCCESS;
}
 
開發者ID:Pl4gue,項目名稱:homeworkManager-android,代碼行數:14,代碼來源:GetHomeworkPresenter.java

示例13: acquireGooglePlayServices

import com.google.android.gms.common.GoogleApiAvailability; //導入方法依賴的package包/類
/**
 * Attempt to resolve a missing, out-of-date, invalid or disabled Google
 * Play Services installation via a user dialog, if possible.
 */
private void acquireGooglePlayServices() {
    GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
    final int connectionStatusCode = apiAvailability.isGooglePlayServicesAvailable(getContext());
    if (apiAvailability.isUserResolvableError(connectionStatusCode)) {
        showGooglePlayServicesAvailabilityErrorDialog(connectionStatusCode);
    }
}
 
開發者ID:piskula,項目名稱:FuelUp,代碼行數:12,代碼來源:BackupFragment.java

示例14: isGooglePlayServicesAvailable

import com.google.android.gms.common.GoogleApiAvailability; //導入方法依賴的package包/類
/**
 * Check that Google Play services APK is installed and up to date.
 *
 * @return true if Google Play Services is available and up to
 * date on this device; false otherwise.
 */
private boolean isGooglePlayServicesAvailable() {
    GoogleApiAvailability apiAvailability =
            GoogleApiAvailability.getInstance();
    final int connectionStatusCode =
            apiAvailability.isGooglePlayServicesAvailable(getActivity());
    return connectionStatusCode == ConnectionResult.SUCCESS;
}
 
開發者ID:mkeresztes,項目名稱:AndiCar,代碼行數:14,代碼來源:PreferenceActivity.java

示例15: checkPlayServices

import com.google.android.gms.common.GoogleApiAvailability; //導入方法依賴的package包/類
/**
 * Function to check google play services
 *
 * @return Found or not
 */
private boolean checkPlayServices() {
    GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
    int result = googleAPI.isGooglePlayServicesAvailable(context);
    if (result != ConnectionResult.SUCCESS) {
        if (googleAPI.isUserResolvableError(result)) {
            googleAPI.getErrorDialog((Activity) context, result,
                    1).show();
        }

        return false;
    }

    return true;
}
 
開發者ID:fekracomputers,項目名稱:MuslimMateAndroid,代碼行數:20,代碼來源:FusedLocationService.java


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