本文整理汇总了Java中com.google.android.gms.common.ConnectionResult.SUCCESS属性的典型用法代码示例。如果您正苦于以下问题:Java ConnectionResult.SUCCESS属性的具体用法?Java ConnectionResult.SUCCESS怎么用?Java ConnectionResult.SUCCESS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.android.gms.common.ConnectionResult
的用法示例。
在下文中一共展示了ConnectionResult.SUCCESS属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkGooglePlayServices
/**
* A utility method to validate that the appropriate version of the Google Play Services is
* available on the device. If not, it will open a dialog to address the issue. The dialog
* displays a localized message about the error and upon user confirmation (by tapping on
* dialog) will direct them to the Play Store if Google Play services is out of date or
* missing, or to system settings if Google Play services is disabled on the device.
*/
public static boolean checkGooglePlayServices(final Activity activity) {
final int googlePlayServicesCheck = GooglePlayServicesUtil.isGooglePlayServicesAvailable(
activity);
switch (googlePlayServicesCheck) {
case ConnectionResult.SUCCESS:
return true;
default:
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(googlePlayServicesCheck,
activity, 0);
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
activity.finish();
}
});
dialog.show();
}
return false;
}
示例2: configureJobManager
private static JobManager configureJobManager(Context context) {
Configuration.Builder builder = new Configuration.Builder(context)
.minConsumerCount(1)//always keep at least one consumer alive
.maxConsumerCount(3)//up to 3 consumers at a time
.loadFactor(3)//3 jobs per consumer
.consumerKeepAlive(120)//wait 2 minutes
.customLogger(customLogger);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder.scheduler(FrameworkJobSchedulerService.createSchedulerFor(context,
SchedulerJobService.class), true);
} else {
int enableGcm = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context);
if (enableGcm == ConnectionResult.SUCCESS) {
builder.scheduler(GcmJobSchedulerService.createSchedulerFor(context,
GcmJobSchedulerService.class), true);
}
}
return new JobManager(builder.build());
}
示例3: checkPlayServices
/**
* 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;
}
示例4: checkPlayServices
/**
* 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;
}
示例5: isGooglePlayServicesAvailable
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;
}
示例6: checkPlayServicesAvailable
/**
* 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.
*
* @param activity activity where you check Google Play Services availability
*/
public boolean checkPlayServicesAvailable(Activity activity) {
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
int resultCode = apiAvailability.isGooglePlayServicesAvailable(activity);
if (resultCode != ConnectionResult.SUCCESS) {
if (apiAvailability.isUserResolvableError(resultCode)) {
apiAvailability.getErrorDialog(activity, resultCode, PLAY_SERVICES_REQUEST_CODE)
.show();
} else {
Log.i(TAG, "This device is not supported.");
activity.finish();
}
return false;
}
return true;
}
示例7: onResume
@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();
}
}
示例8: isGooglePlayServicesAvailable
/**
* 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;
}
示例9: startCameraSource
private void startCameraSource() {
// check that the device has play services available.
int code =
GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(getApplicationContext());
if (code != ConnectionResult.SUCCESS) {
GoogleApiAvailability.getInstance().getErrorDialog(this, code, RC_HANDLE_GMS).show();
}
if (cameraSource != null) {
preview.start(cameraSource, graphicOverlay, PRINTED_CARD_RATIO);
}
}
示例10: isGooglePlayServicesAvailable
/**
* 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;
}
示例11: checkAvailability
@Override
@SuppressWarnings("unchecked")
public void checkAvailability(@NonNull final Context context, @NonNull PaymentMethod paymentMethod,
@NonNull final PaymentMethodAvailabilityCallback callback) {
Log.d(TAG, "checkAvailability");
GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
int result = googleAPI.isGooglePlayServicesAvailable(context);
if (result != ConnectionResult.SUCCESS) {
callback.onFail(new GoogleApiClientNotInitializedException("Google API not available"));
}
final GoogleApiClient googleApiClient = getGoogleApiClient(context);
if (googleApiClient != null) {
googleApiClient.connect();
Wallet.Payments.isReadyToPay(googleApiClient).setResultCallback(
new ResultCallback<BooleanResult>() {
@Override
public void onResult(@NonNull BooleanResult booleanResult) {
if (booleanResult.getStatus().isSuccess()) {
callback.onSuccess(booleanResult.getValue());
} else {
Log.e(TAG, "isReadyToPay:" + booleanResult.getStatus());
String errorMessage = booleanResult.getStatus().getStatusCode()
+ booleanResult.getStatus().getStatusMessage();
callback.onFail(new Throwable(errorMessage));
}
}
});
} else {
callback.onFail(new GoogleApiClientNotInitializedException(
"Google API client is null or not connected"));
}
}
示例12: checkPlayServices
private boolean checkPlayServices() {
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
GooglePlayServicesUtil.getErrorDialog(resultCode, this,
PLAY_SERVICES_RESOLUTION_REQUEST).show();
} else {
finish();
}
return false;
}
return true;
}
示例13: checkPlayServices
/**
* 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;
}
示例14: checkGooglePlayService
private void checkGooglePlayService() {
GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
int result = googleAPI.isGooglePlayServicesAvailable(this);
if(result != ConnectionResult.SUCCESS) {
if (googleAPI.isUserResolvableError(result)) {
googleAPI.getErrorDialog(this, result,
0).show();
}
}
}
示例15: servicesAvailable
private boolean servicesAvailable() {
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity());
if (ConnectionResult.SUCCESS == resultCode) {
return true;
} else {
GooglePlayServicesUtil.getErrorDialog(resultCode, getActivity(), 0).show();
return false;
}
}