0
문제가 있습니다. 내 앱의 google 로그인 버튼이 작동하지 않습니다. 내가 추가 한 페이스 북 기능 때문입니다.페이 스북 단추를 추가 한 후 google 로그인 버튼이 작동하지 않습니다.
FacebookSdk.sdkInitialize(getApplicationContext());
setContentView(R.layout.activity_gesta_main);
mCallbackManager = CallbackManager.Factory.create();
LoginButton mLoginButton = (LoginButton) findViewById(R.id.login_button);
mLoginButton.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
String userLoginId = loginResult.getAccessToken().getUserId();
Intent facebookIntent = new Intent(GestaMainActivity.this, Facebook_login.class);
Profile mProfile = Profile.getCurrentProfile();
String firstName = mProfile.getFirstName();
String lastName = mProfile.getLastName();
String userId = mProfile.getId().toString();
String profileImageUrl = mProfile.getProfilePictureUri(96, 96).toString();
facebookIntent.putExtra(PROFILE_USER_ID, userId);
facebookIntent.putExtra(PROFILE_FIRST_NAME, firstName);
facebookIntent.putExtra(PROFILE_LAST_NAME, lastName);
facebookIntent.putExtra(PROFILE_IMAGE_URL, profileImageUrl);
startActivity(facebookIntent);
}
@Override
public void onCancel() {
}
@Override
public void onError(FacebookException error) {
}
이 문제를 해결하는 방법이 있나요 : 나는에 만드는 방법에서이 기능을 제거 할 때 에서 구글 기호는이 모든 문제를 cuase하는 방법입니다, 괜찮 았는데?
public class GestaMainActivity extends AppCompatActivity implements GoogleApiClient.OnConnectionFailedListener{
private SignInButton btnLogin;
private GoogleSignInOptions googleSignInOptions;
private GoogleApiClient googleApiClient;
private ProgressDialog mConnectionProgressDialog;
private static final int REQUEST_CODE_LOGIN = 10;
public static final String PROFILE_GOOGLE = "PROFILE_FIRST_NAME";
public static final String PROFILE_GOOGLE_EMAIL = "PROFILE_LAST_NAME";
public static final String PROFILE_GOOGLE_IMAGE_URL = "PROFILE_IMAGE_URL";
LoginButton mLoginButton;
private CallbackManager mCallbackManager;
public static final String PROFILE_USER_ID = "USER_ID";
public static final String PROFILE_FIRST_NAME = "PROFILE_FIRST_NAME";
public static final String PROFILE_LAST_NAME = "PROFILE_LAST_NAME";
public static final String PROFILE_IMAGE_URL = "PROFILE_IMAGE_URL";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gesta_main);
setTitle("Gesta App");
googleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().requestProfile().build();
googleApiClient = new GoogleApiClient.Builder(this).enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, googleSignInOptions).addApi(Plus.API).build();
btnLogin = (SignInButton) findViewById(R.id.signin_button_google);
btnLogin.setSize(SignInButton.SIZE_STANDARD);
btnLogin.setScopes(googleSignInOptions.getScopeArray());
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent signin = Auth.GoogleSignInApi.getSignInIntent(googleApiClient);
startActivityForResult(signin, REQUEST_CODE_LOGIN);
}
});
FacebookSdk.sdkInitialize(getApplicationContext());
setContentView(R.layout.activity_gesta_main);
mCallbackManager = CallbackManager.Factory.create();
LoginButton mLoginButton = (LoginButton) findViewById(R.id.login_button);
mLoginButton.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
String userLoginId = loginResult.getAccessToken().getUserId();
Intent facebookIntent = new Intent(GestaMainActivity.this, Facebook_login.class);
Profile mProfile = Profile.getCurrentProfile();
String firstName = mProfile.getFirstName();
String lastName = mProfile.getLastName();
String userId = mProfile.getId().toString();
String profileImageUrl = mProfile.getProfilePictureUri(96, 96).toString();
facebookIntent.putExtra(PROFILE_USER_ID, userId);
facebookIntent.putExtra(PROFILE_FIRST_NAME, firstName);
facebookIntent.putExtra(PROFILE_LAST_NAME, lastName);
facebookIntent.putExtra(PROFILE_IMAGE_URL, profileImageUrl);
startActivity(facebookIntent);
}
@Override
public void onCancel() {
}
@Override
public void onError(FacebookException error) {
}
});
mConnectionProgressDialog = new ProgressDialog(this);
mConnectionProgressDialog.setMessage("Signing in...");}
protected void onActivityResult(int requestcode, int resultcode, Intent data)
{
super.onActivityResult(requestcode,resultcode,data);
mCallbackManager.onActivityResult(requestcode, resultcode, data);
if (requestcode==REQUEST_CODE_LOGIN)
{
GoogleSignInResult googleSignInResult = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
GoogleSignInAccount account = googleSignInResult.getSignInAccount();
Person profile = Plus.PeopleApi.getCurrentPerson(googleApiClient);
try {
Intent sendData = new Intent(GestaMainActivity.this,Google_Gesta.class);
String name, email, dpurl;
name = account.getDisplayName();
email = account.getEmail();
dpurl = account.getPhotoUrl() != null ? account.getPhotoUrl().toString() : null;
sendData.putExtra(PROFILE_GOOGLE,name);
sendData.putExtra(PROFILE_GOOGLE_EMAIL,email);
sendData.putExtra(PROFILE_GOOGLE_IMAGE_URL,dpurl);
startActivity(sendData);
}catch (Exception e)
{
Toast.makeText(GestaMainActivity.this,e.getMessage(),Toast.LENGTH_SHORT).show();
}
}else{
Toast.makeText(GestaMainActivity.this,"Login Failed",Toast.LENGTH_LONG);
}
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
}
@Override
protected void onResume() {
super.onResume();
AppEventsLogger.activateApp(this);
}
@Override
protected void onPause() {
super.onPause();
AppEventsLogger.deactivateApp(this);
}
에서
에서 모든 정보를 얻을 수 있습니다 나는 콜백 메소드에 시도/캐치를 추가하여이 문제를 해결 –