当前位置: 首页>>代码示例>>Java>>正文


Java GooglePlayServicesUtil.isGooglePlayServicesAvailable方法代码示例

本文整理汇总了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;
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:21,代码来源:PlayServicesUtils.java

示例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();
    }
}
 
开发者ID:rsippl,项目名称:AndroidProgramming3e,代码行数:22,代码来源:MockWalkerActivity.java

示例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;
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:27,代码来源:Utils.java

示例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;*/
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:20,代码来源:ApplicationLoader.java

示例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;
    }
 
开发者ID:WasimMemon,项目名称:SocialSignIn_Demo,代码行数:18,代码来源:Utility.java

示例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;
    }
 
开发者ID:juanjecilla,项目名称:FindMeAHome,代码行数:20,代码来源:LocationFragment.java

示例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);
    }
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:19,代码来源:GcmRefreshJob.java

示例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;
}
 
开发者ID:mxiao6,项目名称:Tower-develop,代码行数:29,代码来源:FlightDataFragment.java

示例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;
}
 
开发者ID:The-WebOps-Club,项目名称:saarang-iosched,代码行数:21,代码来源:PlayServicesUtils.java

示例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()));
}
 
开发者ID:CheDream-Android,项目名称:CheDream,代码行数:21,代码来源:ContactsFragment.java

示例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;
}
 
开发者ID:guglielmino,项目名称:pushetta-android-app,代码行数:21,代码来源:MainActivity.java

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

}
 
开发者ID:DiogoPeres,项目名称:WhosUp,代码行数:19,代码来源:GCMActivity.java

示例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;
}
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:15,代码来源:LoginActivity.java

示例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();
}
 
开发者ID:Magicrafter13,项目名称:1946,代码行数:44,代码来源:BaseGameUtils.java

示例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;
}
 
开发者ID:Mun0n,项目名称:MADBike,代码行数:14,代码来源:HomeActivity.java


注:本文中的com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。