我正在尝试使用 google pluse 自动登录。
我使用 SignInButton 按钮小部件。
当我点击登录时,我看到了进度对话框,但 onConnected 没有被触发
这是我的按钮代码:
case R.id.sign_in_button:
{
if(!mPlusClient.isConnected())
{
if (mConnectionResult == null) {
{
pDialog = new ProgressDialog(RegisterPage.this);
pDialog.setMessage("logging in...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
} else {
try {
mConnectionResult.startResolutionForResult(this, REQUEST_CODE_RESOLVE_ERR);
} catch (SendIntentException e) {
// Try connecting again.
mConnectionResult = null;
mPlusClient.connect();
}
}
break;
}
我的 onConnected 代码:
@Override
public void onConnected(Bundle arg0) {
// TODO Auto-generated method stub
Log.i("ok", "ok");
if (mPlusClient.getCurrentPerson() != null && isNetworkAvailable())
new GooglePlusRegister().execute();
else
{
if(pDialog != null)
pDialog.dismiss();
Toast.makeText(getApplicationContext(),"No internet connection", Toast.LENGTH_SHORT).show();
}
}
进度对话框没有显示,我没有看到我的日志调用。
在我的 onCreate 中:
mPlusClient = new PlusClient.Builder(this, this , this).setScopes(Scopes.PLUS_LOGIN).setVisibleActivities("http://schemas.google.com/AddActivity", "http://schemas.google.com/BuyActivity").build();
进口:
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesClient.ConnectionCallbacks;
import com.google.android.gms.common.GooglePlayServicesClient.OnConnectionFailedListener;
import com.google.android.gms.common.Scopes;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.plus.PlusClient;
import com.google.android.gms.plus.model.people.Person;