本文整理匯總了Java中com.google.android.gms.common.ConnectionResult.SERVICE_MISSING屬性的典型用法代碼示例。如果您正苦於以下問題:Java ConnectionResult.SERVICE_MISSING屬性的具體用法?Java ConnectionResult.SERVICE_MISSING怎麽用?Java ConnectionResult.SERVICE_MISSING使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.google.android.gms.common.ConnectionResult
的用法示例。
在下文中一共展示了ConnectionResult.SERVICE_MISSING屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkGooglePlayServices
public static boolean checkGooglePlayServices(final Activity activity) {
final int googlePlayServicesCheck = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
switch (googlePlayServicesCheck) {
case ConnectionResult.SUCCESS:
return true;
case ConnectionResult.SERVICE_DISABLED:
case ConnectionResult.SERVICE_INVALID:
case ConnectionResult.SERVICE_MISSING:
case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
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: checkPlayServices
private PlayServicesStatus checkPlayServices(Context context) {
int gcmStatus = 0;
try {
gcmStatus = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context);
} catch (Throwable t) {
Log.w(TAG, t);
return PlayServicesStatus.MISSING;
}
Log.w(TAG, "Play Services: " + gcmStatus);
switch (gcmStatus) {
case ConnectionResult.SUCCESS:
return PlayServicesStatus.SUCCESS;
case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
return PlayServicesStatus.NEEDS_UPDATE;
case ConnectionResult.SERVICE_DISABLED:
case ConnectionResult.SERVICE_MISSING:
case ConnectionResult.SERVICE_INVALID:
case ConnectionResult.API_UNAVAILABLE:
case ConnectionResult.SERVICE_MISSING_PERMISSION:
return PlayServicesStatus.MISSING;
default:
return PlayServicesStatus.TRANSIENT_ERROR;
}
}
示例3: errorCodeToString
static String errorCodeToString(int errorCode) {
switch (errorCode) {
case ConnectionResult.DEVELOPER_ERROR:
return "DEVELOPER_ERROR(" + errorCode + ")";
case ConnectionResult.INTERNAL_ERROR:
return "INTERNAL_ERROR(" + errorCode + ")";
case ConnectionResult.INVALID_ACCOUNT:
return "INVALID_ACCOUNT(" + errorCode + ")";
case ConnectionResult.LICENSE_CHECK_FAILED:
return "LICENSE_CHECK_FAILED(" + errorCode + ")";
case ConnectionResult.NETWORK_ERROR:
return "NETWORK_ERROR(" + errorCode + ")";
case ConnectionResult.RESOLUTION_REQUIRED:
return "RESOLUTION_REQUIRED(" + errorCode + ")";
case ConnectionResult.SERVICE_DISABLED:
return "SERVICE_DISABLED(" + errorCode + ")";
case ConnectionResult.SERVICE_INVALID:
return "SERVICE_INVALID(" + errorCode + ")";
case ConnectionResult.SERVICE_MISSING:
return "SERVICE_MISSING(" + errorCode + ")";
case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
return "SERVICE_VERSION_UPDATE_REQUIRED(" + errorCode + ")";
case ConnectionResult.SIGN_IN_REQUIRED:
return "SIGN_IN_REQUIRED(" + errorCode + ")";
case ConnectionResult.SUCCESS:
return "SUCCESS(" + errorCode + ")";
default:
return "Unknown error code " + errorCode;
}
}
示例4: isGooglePlayServicesMissing
/**
* @return Whether the current device lacks proper Google Play Services. This will return true
* if the service is not authentic or it is totally missing. Return false otherwise.
* Note this method returns false if the service is only temporarily disabled, such as
* when it is updating.
*/
public boolean isGooglePlayServicesMissing(final Context context) {
final int resultCode = checkGooglePlayServicesAvailable(context);
if (resultCode == ConnectionResult.SERVICE_MISSING
|| resultCode == ConnectionResult.SERVICE_INVALID) {
return true;
}
return false;
}
示例5: isGooglePlayServicesUpdateRequiredError
/**
* @param errorCode returned by {@link #checkGooglePlayServicesAvailable(Context)}.
* @return true if the error code indicates that an invalid version of Google Play Services is
* installed.
*/
public boolean isGooglePlayServicesUpdateRequiredError(int errorCode) {
return errorCode == ConnectionResult.SERVICE_UPDATING
|| errorCode == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED
|| errorCode == ConnectionResult.SERVICE_DISABLED
|| errorCode == ConnectionResult.SERVICE_MISSING;
}
示例6: onConnectionFailed
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
// ConnectionResult參數是連線失敗的資訊
int errorCode = connectionResult.getErrorCode();
// 裝置沒有安裝Google Play服務
if (errorCode == ConnectionResult.SERVICE_MISSING) {
Toast.makeText(this, R.string.google_play_service_missing, Toast.LENGTH_LONG).show();
}
}
示例7: onCreate
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// uncomment to test other locales
/*
if ((Build.VERSION.SDK_INT >= 17)&&(Build.VERSION.SDK_INT < 25)) {
String mLang = "fr"; // change to your test language
String mCountry = "FR"; // change to your test country
Configuration mConfig;
Locale mLocale;
if (mCountry.hashCode() == "".hashCode()) {
mLocale = new Locale(mLang);
} else {
mLocale = new Locale(mLang, mCountry);
}
Locale.setDefault(mLocale);
mConfig = getBaseContext().getResources().getConfiguration();
mConfig.setLocale(mLocale);
mConfig.setLayoutDirection(mLocale);
Resources resources = getBaseContext().getResources();
resources.updateConfiguration(mConfig, resources.getDisplayMetrics());
}
*/
// callback listener.
AppRate.with(this)
.setStoreType(StoreType.GOOGLEPLAY) //default is GOOGLEPLAY (Google Play), other options are
// AMAZON (Amazon Appstore) and
// SAMSUNG (Samsung Galaxy Apps)
.setInstallDays((byte) 3) // default 10, 0 means install day.
.setLaunchTimes((byte) 10) // default 10 times.
.setRemindInterval((byte) 2) // default 1 day.
.setRemindLaunchTimes ((byte) 4) // default 1 (each launch).
.setShowLaterButton(true) // default true.
.setDebug(true) // default false.
.setCancelable(false) // default false.
.setOnClickButtonListener(which -> Log.d(TAG, "RateButton: " + Byte.toString(which) + ""))
// comment to use library strings instead app strings
.setTitle(R.string.new_rate_dialog_title)
.setTextLater(R.string.new_rate_dialog_later)
// uncomment to use app string instead library string
//.setMessage(R.string.new_rate_dialog_message)
// comment to use library strings instead app strings
.setTextNever(R.string.new_rate_dialog_never)
.setTextRateNow(R.string.new_rate_dialog_ok)
.monitor();
//noinspection ConstantConditions
if (AppRate.with(this).getStoreType() == StoreType.GOOGLEPLAY) {
//Check that Google Play is available
if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this) != ConnectionResult.SERVICE_MISSING) {
// Show a dialog if meets conditions
AppRate.showRateDialogIfMeetsConditions(this);
}
} else {
// Show a dialog if meets conditions
AppRate.showRateDialogIfMeetsConditions(this);
}
}