本文整理汇总了Java中com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable方法的典型用法代码示例。如果您正苦于以下问题:Java GooglePlayServicesUtil.isGooglePlayServicesAvailable方法的具体用法?Java GooglePlayServicesUtil.isGooglePlayServicesAvailable怎么用?Java GooglePlayServicesUtil.isGooglePlayServicesAvailable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.common.GooglePlayServicesUtil
的用法示例。
在下文中一共展示了GooglePlayServicesUtil.isGooglePlayServicesAvailable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkGooglePlayServices
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
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: onResume
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
@Override
protected void onResume() {
super.onResume();
int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (errorCode != ConnectionResult.SUCCESS) {
Dialog errorDialog = GooglePlayServicesUtil
.getErrorDialog(errorCode, this, REQUEST_ERROR,
new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
// Leave if services are unavailable.
finish();
}
});
errorDialog.show();
}
}
示例3: checkGooglePlayServices
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
/**
* 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;
}
示例4: checkPlayServices
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
private boolean checkPlayServices() {
try {
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
return resultCode == ConnectionResult.SUCCESS;
} catch (Exception e) {
FileLog.e("tmessages", e);
}
return true;
/*if (resultCode != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
GooglePlayServicesUtil.getErrorDialog(resultCode, this, PLAY_SERVICES_RESOLUTION_REQUEST).show();
} else {
Log.i("tmessages", "This device is not supported.");
}
return false;
}
return true;*/
}
示例5: checkPlayServices
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
public static boolean checkPlayServices(Context act) {
Activity activity = (Activity)act;
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
if (resultCode != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
GooglePlayServicesUtil.getErrorDialog(resultCode, activity,
AppConstants.PLAY_SERVICES_RESOLUTION_REQUEST).show();
} else {
Log.i("checkPlayServices", "This device is not supported.");
activity.finish();
}
return false;
}
return true;
}
示例6: checkPlayServices
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
private boolean checkPlayServices() {
int resultCode = GooglePlayServicesUtil
.isGooglePlayServicesAvailable(getActivity());
if (resultCode != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
GooglePlayServicesUtil.getErrorDialog(resultCode, getActivity(),
PLAY_SERVICES_RESOLUTION_REQUEST).show();
} else {
Toast.makeText(getContext(),
getString(R.string.location_services_not_supported), Toast.LENGTH_LONG)
.show();
getActivity().finish();
}
return false;
}
return true;
}
示例7: onRun
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
@Override
public void onRun() throws Exception {
TextSecureAccountManager accountManager = TextSecureCommunicationFactory.createManager(context);
String registrationId = TextSecurePreferences.getGcmRegistrationId(context);
if (registrationId == null) {
Log.w(TAG, "GCM registrationId expired, reregistering...");
int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);
if (result != ConnectionResult.SUCCESS) {
notifyGcmFailure();
} else {
String gcmId = GoogleCloudMessaging.getInstance(context).register(REGISTRATION_ID);
accountManager.setGcmId(Optional.of(gcmId));
TextSecurePreferences.setGcmRegistrationId(context, gcmId);
}
}
}
示例8: isGooglePlayServicesValid
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
/**
* Ensures that the device has the correct version of the Google Play
* Services.
*
* @return true if the Google Play Services binary is valid
*/
private boolean isGooglePlayServicesValid(boolean showErrorDialog) {
// Check for the google play services is available
final int playStatus = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getContext());
final boolean isValid = playStatus == ConnectionResult.SUCCESS;
if (!isValid && showErrorDialog) {
final Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(playStatus, getActivity(),
GOOGLE_PLAY_SERVICES_REQUEST_CODE, new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
if (isAdded()) {
getActivity().finish();
}
}
});
if (errorDialog != null)
errorDialog.show();
}
return isValid;
}
示例9: checkGooglePlaySevices
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
public static boolean checkGooglePlaySevices(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;
}
示例10: onViewCreated
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mMapView = (MapView) view.findViewById(R.id.mapView);
mMapView.onCreate(savedInstanceState);
mMapView.onResume();
boolean isGooglePlayServicesAvailable = ConnectionResult.SUCCESS ==
GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity());
if (isGooglePlayServicesAvailable) {
setMap();
} else {
mMapView.setVisibility(View.GONE);
}
ListView listViewContacts = (ListView) view.findViewById(R.id.listview_contacts);
listViewContacts.setAdapter(new ContactsAdapter(getActivity()));
}
示例11: checkPlayServices
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
/**
* Check if Google Cloud Messaging is avaiable for the device
*
* @return
*/
private boolean checkPlayServices() {
int resultCode = GooglePlayServicesUtil
.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
GooglePlayServicesUtil.getErrorDialog(resultCode, this,
PushettaConsts.PLAY_SERVICES_RESOLUTION_REQUEST).show();
} else {
Log.i(PushettaConsts.TAG, "This device is not supported.");
finish();
}
return false;
}
return true;
}
示例12: isGoogelPlayInstalled
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
private boolean isGoogelPlayInstalled() {
int resultCode = GooglePlayServicesUtil
.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
GooglePlayServicesUtil.getErrorDialog(resultCode, this,
ACTION_PLAY_SERVICES_DIALOG).show();
} else {
Toast.makeText(getApplicationContext(),
"Google Play Service is not installed",
Toast.LENGTH_SHORT).show();
finish();
}
return false;
}
return true;
}
示例13: checkPlayServices
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
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 {
Log.i(TAG, "This device is not supported.");
finish();
}
return false;
}
return true;
}
示例14: showActivityResultError
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
/**
* Show a {@link android.app.Dialog} with the correct message for a connection error.
* @param activity the Activity in which the Dialog should be displayed.
* @param requestCode the request code from onActivityResult.
* @param actResp the response code from onActivityResult.
* @param errorDescription the resource id of a String for a generic error message.
*/
public static void showActivityResultError(Activity activity, int requestCode, int actResp, int errorDescription) {
if (activity == null) {
Log.e("BaseGameUtils", "*** No Activity. Can't show failure dialog!");
return;
}
Dialog errorDialog;
switch (actResp) {
case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
errorDialog = makeSimpleDialog(activity,
activity.getString(R.string.app_misconfigured));
break;
case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
errorDialog = makeSimpleDialog(activity,
activity.getString(R.string.sign_in_failed));
break;
case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
errorDialog = makeSimpleDialog(activity,
activity.getString(R.string.license_failed));
break;
default:
// No meaningful Activity response code, so generate default Google
// Play services dialog
final int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
activity, requestCode, null);
if (errorDialog == null) {
// get fallback dialog
Log.e("BaseGamesUtils",
"No standard error dialog available. Making fallback dialog.");
errorDialog = makeSimpleDialog(activity, activity.getString(errorDescription));
}
}
errorDialog.show();
}
示例15: checkPlayServices
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
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;
}