Android 如何定制谷歌登录按钮?
我想根据我的设计定制谷歌登录按钮 图像已附加Android 如何定制谷歌登录按钮?,android,xml,android-layout,Android,Xml,Android Layout,我想根据我的设计定制谷歌登录按钮 图像已附加 在UI中创建任意按钮,并在单击按钮时调用此功能 public void gPlusSignIn() { GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() .build(); GoogleApiClient mGoogleApiCli
在UI中创建任意按钮,并在单击按钮时调用此功能
public void gPlusSignIn() {
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(YourActivity.this)
.enableAutoManage(YourActivity.this /* Activity */
, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
}
Google将以onActivityResult方法为您提供登录响应:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
GoogleSignInAccount acct = result.getSignInAccount();
//get user's email
String mEmail = acct.getEmail();
//get user's full name
String mFullName = acct.getDisplayName();
String gPlusID = acct.getId();
}
}
}
您可以将任何按钮作为谷歌登录按钮创建框架布局,将您的
按钮置于默认谷歌登录按钮下方。同样,我们也可以为facebook使用任何按钮@jagapathiyes我们可以@sunilpi如果我们也为facebook使用任何按钮,我们会获得registerCallback方法吗@贾加帕蒂