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


Java GooglePlayServicesUtil.getErrorDialog方法代码示例

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

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

示例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();
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:18,代码来源:LoginAndAuthHelper.java

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

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

示例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;
}
 
开发者ID:Peter-Wilson,项目名称:Flock,代码行数:22,代码来源:MainActivity.java

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

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

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

示例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;
}
 
开发者ID:akalongman,项目名称:android-helloworld,代码行数:30,代码来源:PlayServices.java

示例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;
}
 
开发者ID:BruGTUG,项目名称:codelab-chromecast,代码行数:30,代码来源:Utils.java

示例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;
}
 
开发者ID:sommishra,项目名称:DroidPlanner-Tower,代码行数:28,代码来源:FlightActivity.java

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

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

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


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