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


Java GoogleApiAvailability.isGooglePlayServicesAvailable方法代碼示例

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


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

示例1: isGooglePlayServicesAvailable

import com.google.android.gms.common.GoogleApiAvailability; //導入方法依賴的package包/類
public boolean isGooglePlayServicesAvailable() {
    GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
    int code = googleApiAvailability.isGooglePlayServicesAvailable(context);
    if (code != ConnectionResult.SUCCESS) {
        if (googleApiAvailability.isUserResolvableError(code)) {
            googleApiAvailability.getErrorDialog(context, code, PLAY_SERVICE_RESOLUTION_REQUEST, this);
        } else {
            showLog("THIS DEVICE IS NOT SUPPORTED");
            Util.killAppProccess();
        }
        showLog("isGooglePlayServicesAvailable - " + "false");
        return false;
    }
    showLog("isGooglePlayServicesAvailable - " + "true");
    return true;
}
 
開發者ID:pedromassango,項目名稱:Programmers,代碼行數:17,代碼來源:GoogleServices.java

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

示例3: checkPlayServices

import com.google.android.gms.common.GoogleApiAvailability; //導入方法依賴的package包/類
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,代碼行數:20,代碼來源:MainWearActivity.java

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

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

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

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

示例8: checkForPlayServices

import com.google.android.gms.common.GoogleApiAvailability; //導入方法依賴的package包/類
private boolean checkForPlayServices() {
    GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
    int resultCode = googleApiAvailability
            .isGooglePlayServicesAvailable(getReactApplicationContext());
    if (resultCode != ConnectionResult.SUCCESS) {
        if (googleApiAvailability.isUserResolvableError(resultCode)) {
            googleApiAvailability.getErrorDialog(getCurrentActivity(), resultCode,
                    PLAY_SERVICES_RESOLUTION_REQUEST).show();
        }
        return false;
    }
    return true;
}
 
開發者ID:MustansirZia,項目名稱:react-native-fused-location,代碼行數:14,代碼來源:FusedLocationModule.java

示例9: checkPlayServices

import com.google.android.gms.common.GoogleApiAvailability; //導入方法依賴的package包/類
private boolean checkPlayServices(){
	GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
	int resultCode = googleApiAvailability.isGooglePlayServicesAvailable(mActivity);
	if(resultCode != ConnectionResult.SUCCESS) {
		if(googleApiAvailability.isUserResolvableError(resultCode)) {
			if(mErrorDialog == null) {
				mErrorDialog = googleApiAvailability.getErrorDialog(mActivity, resultCode, 2404);
				mErrorDialog.setCancelable(false);
			}
			if(!mErrorDialog.isShowing())
				mErrorDialog.show();
		}
	}
	return resultCode == ConnectionResult.SUCCESS;
}
 
開發者ID:Skullper,項目名稱:SimpleLocationGetter,代碼行數:16,代碼來源:SimpleLocationGetter.java

示例10: 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(getActivity());
    if (apiAvailability.isUserResolvableError(connectionStatusCode)) {
        SharedPreferences settings = getPreferenceManager().getSharedPreferences();
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(getString(R.string.pref_key_secure_backup_enabled), false);
        editor.apply();
        showGooglePlayServicesAvailabilityErrorDialog(connectionStatusCode);
    }
}
 
開發者ID:mkeresztes,項目名稱:AndiCar,代碼行數:18,代碼來源:PreferenceActivity.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(this);
	if (resultCode != ConnectionResult.SUCCESS) {
		if (apiAvailability.isUserResolvableError(resultCode)) {
			apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
					.show();
		} else {
			finish();
		}
		return false;
	}
	return true;
}
 
開發者ID:mityung,項目名稱:XERUNG,代碼行數:20,代碼來源:VerifyOTP.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(this);
    return connectionStatusCode == ConnectionResult.SUCCESS;
}
 
開發者ID:jcolladosp,項目名稱:ePills,代碼行數:13,代碼來源:ClockActivity.java

示例13: googleplayservice

import com.google.android.gms.common.GoogleApiAvailability; //導入方法依賴的package包/類
public boolean googleplayservice() {
    GoogleApiAvailability api = GoogleApiAvailability.getInstance();
    int isAvaible = api.isGooglePlayServicesAvailable(this);
    if (isAvaible == ConnectionResult.SUCCESS) {
        return true;
    } else if (api.isUserResolvableError(isAvaible)) {
        Dialog dialog = api.getErrorDialog(this, isAvaible, 0);
        dialog.show();
    } else {
        Toast.makeText(this, "Can't Connect to play services", Toast.LENGTH_LONG).show();
    }
    return false;
}
 
開發者ID:Francescopaolo44,項目名稱:MedicalMe,代碼行數:14,代碼來源:MapsActivity.java

示例14: checkGooglePlayAvailability

import com.google.android.gms.common.GoogleApiAvailability; //導入方法依賴的package包/類
private boolean checkGooglePlayAvailability() {
    GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
    int resultCode = googleApiAvailability.isGooglePlayServicesAvailable(context);
    if(resultCode == ConnectionResult.SUCCESS) {
        return true;
    } else {
        if(googleApiAvailability.isUserResolvableError(resultCode)) {
            googleApiAvailability.getErrorDialog(MainActivity.this, resultCode, 2404).show();
        }
    }
    return false;
}
 
開發者ID:EzequielAdrianM,項目名稱:Camera2Vision,代碼行數:13,代碼來源:MainActivity.java

示例15: getPlayServicesAvailabilityResultCode

import com.google.android.gms.common.GoogleApiAvailability; //導入方法依賴的package包/類
private int getPlayServicesAvailabilityResultCode() {
    GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
    return apiAvailability.isGooglePlayServicesAvailable(CoreApp.getInstance());
}
 
開發者ID:mobilemaster128,項目名稱:quickblox-android,代碼行數:5,代碼來源:GooglePlayServicesHelper.java


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