无法使用手册中的代码 (GoogleApiClient)
Can't use code from manual (GoogleApiClient)
我使用来自 this page 的代码。
第一个问题 - 我复制并粘贴了所有这些代码,但随后我开始这个 activity 我看到带有错误消息的 toast(和屏幕变暗)。
第二个问题 - 我无法使用此代码:
int errorCode = GooglePlusUtil.checkGooglePlusApp(this);
if (errorCode != GooglePlusUtil.SUCCESS) {
GooglePlusUtil.getErrorDialog(errorCode, this, 0).show();
}
我看到这个错误:
此片段来自build.gradle
dependencies {
...
compile 'com.google.android.gms:play-services:6.5.+'
...
}
P.S。我想在我的应用程序中使用 Google Plus 登录。
UPDATE1 SDK 管理器的截图:
/**
* @param activity activity passed from activity that calls checkPlayServices().
* @param context getting the current context from the activity .
*/
public static boolean checkPlayServices(Activity activity, Context context) {
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);
if (resultCode != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
GooglePlayServicesUtil.getErrorDialog(resultCode, activity,
Config.PLAY_SERVICES_RESOLUTION_REQUEST).show();
} else {
Log.i(TAG, "This device is not supported.");
activity.finish();
}
return false;
}
我使用来自 this page 的代码。
第一个问题 - 我复制并粘贴了所有这些代码,但随后我开始这个 activity 我看到带有错误消息的 toast(和屏幕变暗)。
第二个问题 - 我无法使用此代码:
int errorCode = GooglePlusUtil.checkGooglePlusApp(this);
if (errorCode != GooglePlusUtil.SUCCESS) {
GooglePlusUtil.getErrorDialog(errorCode, this, 0).show();
}
我看到这个错误:
dependencies {
...
compile 'com.google.android.gms:play-services:6.5.+'
...
}
P.S。我想在我的应用程序中使用 Google Plus 登录。
UPDATE1 SDK 管理器的截图:
/**
* @param activity activity passed from activity that calls checkPlayServices().
* @param context getting the current context from the activity .
*/
public static boolean checkPlayServices(Activity activity, Context context) {
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);
if (resultCode != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
GooglePlayServicesUtil.getErrorDialog(resultCode, activity,
Config.PLAY_SERVICES_RESOLUTION_REQUEST).show();
} else {
Log.i(TAG, "This device is not supported.");
activity.finish();
}
return false;
}