本文整理汇总了Java中com.google.android.gms.common.GooglePlayServicesUtil.getErrorDialog方法的典型用法代码示例。如果您正苦于以下问题:Java GooglePlayServicesUtil.getErrorDialog方法的具体用法?Java GooglePlayServicesUtil.getErrorDialog怎么用?Java GooglePlayServicesUtil.getErrorDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.common.GooglePlayServicesUtil
的用法示例。
在下文中一共展示了GooglePlayServicesUtil.getErrorDialog方法的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: 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();
}
示例3: showRecoveryDialog
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
private void showRecoveryDialog(int statusCode) {
Activity activity = getActivity("showRecoveryDialog()");
if (activity == null) {
return;
}
if (sCanShowAuthUi) {
sCanShowAuthUi = false;
LOGD(TAG, "Showing recovery dialog for status code " + statusCode);
final Dialog d = GooglePlayServicesUtil.getErrorDialog(
statusCode, activity, REQUEST_RECOVER_FROM_PLAY_SERVICES_ERROR);
d.show();
} else {
LOGD(TAG, "Not showing Play Services recovery dialog because sCanShowSignInUi==false.");
reportAuthFailure();
}
}
示例4: 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;
}
示例5: checkGooglePlayServices
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
private void checkGooglePlayServices() {
int code = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (code != ConnectionResult.SUCCESS) {
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(
code, this, GOOGLE_PLAY_SERVICES_REQUEST_CODE, new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
finish();
}
});
if (dialog != null) {
dialog.show();
return;
}
}
}
示例6: checkGooglePlayServicesAvailable
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
private boolean checkGooglePlayServicesAvailable()
{
final int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
if (status == ConnectionResult.SUCCESS)
{
return true;
}
Log.e("MAIN ACTIVITY", "Google Play Services not available: " + GooglePlayServicesUtil.getErrorString(status));
if (GooglePlayServicesUtil.isUserRecoverableError(status))
{
final Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(status, this, 1);
if (errorDialog != null)
{
errorDialog.show();
}
}
return false;
}
示例7: onResume
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
@Override
public void onResume() {
super.onResume();
// Check that Google Play services is available
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (ConnectionResult.SUCCESS == resultCode) {
Log.d("Location Updates", "Google Play services is available.");
return;
// Google Play services was not available for some reason
} else {
// Get the error dialog from Google Play services
Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(resultCode, this, CONNECTION_FAILURE_RESOLUTION_REQUEST);
// If Google Play services can provide an error dialog
if (errorDialog != null) {
ErrorDialogFragment errorFragment = new ErrorDialogFragment();
errorFragment.setDialog(errorDialog);
errorFragment.show(getSupportFragmentManager(), "Location Updates");
}
}
}
示例8: showErrorDialog
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
private void showErrorDialog(int errorCode) {
// Get the error dialog from Google Play services
Dialog errorDialog =
GooglePlayServicesUtil.getErrorDialog(errorCode, this,
CONNECTION_FAILURE_RESOLUTION_REQUEST);
// If Google Play services can provide an error dialog
if (errorDialog != null) {
// Create a new DialogFragment in which to show the error dialog
ErrorDialogFragment errorFragment = new ErrorDialogFragment();
// Set the dialog in the DialogFragment
errorFragment.setDialog(errorDialog);
// Show the error dialog in the DialogFragment
errorFragment.show(getSupportFragmentManager(), Application.APPTAG);
}
}
示例9: showRecoveryDialog
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
private void showRecoveryDialog(int statusCode) {
Activity activity = getActivity("showRecoveryDialog()");
if (activity == null) {
return;
}
if (sCanShowAuthUi) {
sCanShowAuthUi = false;
LogUtils.LOGD(TAG, "Showing recovery dialog for status code " + statusCode);
final Dialog d = GooglePlayServicesUtil.getErrorDialog(
statusCode, activity, REQUEST_RECOVER_FROM_PLAY_SERVICES_ERROR);
d.show();
} else {
LogUtils.LOGD(TAG, "Not showing Play Services recovery dialog because sCanShowSignInUi==false.");
reportAuthFailure();
}
}
示例10: checkPlayServices
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的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.
*/
public boolean checkPlayServices() {
final int googlePlayServicesCheck = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this.context);
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:
final Activity activity = App.instance().getActivity();
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(googlePlayServicesCheck, activity, 0);
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
activity.finish();
}
});
dialog.show();
}
return false;
}
示例11: 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.
*
* @param activity
* @return
*/
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;
}
示例12: 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(getApplicationContext());
final boolean isValid = playStatus == ConnectionResult.SUCCESS;
if (!isValid && showErrorDialog) {
final Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(playStatus, this,
GOOGLE_PLAY_SERVICES_REQUEST_CODE, new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
finish();
}
});
if (errorDialog != null)
errorDialog.show();
}
return isValid;
}
示例13: showErrorDialog
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
private void showErrorDialog(int errorCode,int requestCode)
{
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(errorCode,RunnerActivity.CurrentActivity, requestCode);
if (dialog != null)
{
dialog.show();
}
else
{
// no built-in dialog: show the fallback error message
// showAlert(RunnerActivity.CurrentActivity, );
Log.i("yoyo","Google Play Services Error and unable to initialise GooglePlayServicesUtil error dialog");
}
}
示例14: resolveConnectionFailure
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
/**
* Resolve a connection failure from
* {@link com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener#onConnectionFailed(com.google.android.gms.common.ConnectionResult)}
*
* @param activity the Activity trying to resolve the connection failure.
* @param client the GoogleAPIClient instance of the Activity.
* @param result the ConnectionResult received by the Activity.
* @param requestCode a request code which the calling Activity can use to identify the result
* of this resolution in onActivityResult.
* @param fallbackErrorMessage a generic error message to display if the failure cannot be resolved.
* @return true if the connection failure is resolved, false otherwise.
*/
public static boolean resolveConnectionFailure(Activity activity,
GoogleApiClient client, ConnectionResult result, int requestCode,
String fallbackErrorMessage) {
if (result.hasResolution()) {
try {
result.startResolutionForResult(activity, requestCode);
return true;
} catch (IntentSender.SendIntentException e) {
// The intent was canceled before it was sent. Return to the default
// state and attempt to connect to get an updated ConnectionResult.
client.connect();
return false;
}
} else {
// not resolvable... so show an error message
int errorCode = result.getErrorCode();
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
activity, requestCode);
if (dialog != null) {
dialog.show();
} else {
// no built-in dialog: show the fallback error message
showAlert(activity, fallbackErrorMessage);
}
return false;
}
}
示例15: onCreateDialog
import com.google.android.gms.common.GooglePlayServicesUtil; //导入方法依赖的package包/类
@Override
public @NonNull Dialog onCreateDialog(@NonNull Bundle bundle) {
int code = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity());
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(code, getActivity(), 9111);
if (dialog == null) {
return new AlertDialog.Builder(getActivity())
.setNegativeButton(android.R.string.ok, null)
.setMessage(R.string.PlayServicesProblemFragment_the_version_of_google_play_services_you_have_installed_is_not_functioning)
.create();
} else {
return dialog;
}
}