Google登录弹出帐户

时间:2015-11-12 04:53:04

标签: android android-fragments

应用中有一个谷歌登录按钮。 现在,当单击该按钮时,它会询问选择登录的帐户。 显示警报对话框以选择帐户的功能是什么?

 public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        findViewById(R.id.sign_in_button).setOnClickListener(this);


        mConnectionProgressDialog = new ProgressDialog(this);
        mConnectionProgressDialog.setMessage("Signing in...");

        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(Plus.API)
                .addScope(new Scope(Scopes.EMAIL))
                .build();

    }



    @Override
    public void onClick(View v) {
         {
            onSignInClicked();
            mConnectionProgressDialog.show();
        }

            }

    private void onSignInClicked() {
        // User clicked the sign-in button, so begin the sign-in process and automatically
        // attempt to resolve any errors that occur.
        mShouldResolve = true;
        mGoogleApiClient.connect();
    }

0 个答案:

没有答案