我在尝试按照示例检查Google Play服务是否安装时,遇到以下错误:"connectionResult无法解析",出现在servicesConnected方法内的那一行。
int errorCode = connectionResult.getErrorCode();
有什么可能会丢失吗?我正在复制和粘贴它。我正在按照这里的示例进行操作。
谢谢!
我在尝试按照示例检查Google Play服务是否安装时,遇到以下错误:"connectionResult无法解析",出现在servicesConnected方法内的那一行。
int errorCode = connectionResult.getErrorCode();
有什么可能会丢失吗?我正在复制和粘贴它。我正在按照这里的示例进行操作。
谢谢!
这个示例中有一个错误。请使用以下内容代替:
} else {
// Get the error code
// Get the error dialog from Google Play services
Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(
resultCode,
this,
CONNECTION_FAILURE_RESOLUTION_REQUEST);
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) {
// Create a new DialogFragment for 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(),
"Location Updates");
}
return false;//THIS NEEDS TO BE FALSE
}
import android.support.v4.app.DialogFragment;
(来源) - tutuDajuju