Android 未触发连接的多客户端
我正在尝试使用谷歌pluse自动登录 我使用SignInButton按钮小部件 当我点击登录时,我看到了进度对话框,但是onConnected没有被触发 这是我的按钮按下代码:Android 未触发连接的多客户端,android,google-plus,Android,Google Plus,我正在尝试使用谷歌pluse自动登录 我使用SignInButton按钮小部件 当我点击登录时,我看到了进度对话框,但是onConnected没有被触发 这是我的按钮按下代码: case R.id.sign_in_button: { if(!mPlusClient.isConnected()) { if (mConnectionResult == null) {
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;
}
我的未连接代码:
@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;
再看看您的代码:
mpluclient.connect()
从未执行过
条件语句if(mConnectionResult==null)
仅显示ProgressDialog,而没有实际连接到Google Plus
我必须回顾一下处理错误条件的正确方法,但是在我的头脑中,简单地删除否则语句的行可能会解决您的问题