Ich erstelle eine App, in die ich facebook sdk
integrieren möchte. Ich möchte Benutzer mit facebook
anmelden, aber es verursacht Problem.Facebook-Integration mit benutzerdefinierten Button
Es funktioniert nur einmal. Wenn ich die App installiere und mich mit facebook
anmelde funktioniert es, aber wenn ich meine App deinstalliere und versuche, mich erneut mit facebook
zu installieren und einzuloggen, funktioniert es nicht. Es fragt nicht access permission
und nichts zu tun.
ich noch eine Frage stellen will, mag ich nächste Activity
individuelle Facebook Login-Button und nach erfolgreicher Anmeldung gehen machen.
Hier was ich bereits getan habe. Ich weiß nicht, wo ist der Fehler?
Hier ist meine Haupt xml:
<ImageButton
android:id="@+id/btnFblogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:onClick="onClick"
android:src="@drawable/fb_signin" />
<com.facebook.login.widget.LoginButton
android:id="@+id/fb_login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
Hier mein Fragment ist:
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
btnFbLog = (ImageButton) view.findViewById(R.id.btnFblogin);
btnFbLog.setOnClickListener(this);
return view;}
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnFblogin:
mSignInClicked = true;
Toast.makeText(getApplicationContext(), "Clicked on facebook login", Toast.LENGTH_SHORT).show();
fbloginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
//updateFacebookButtonUI();
Profile profile = Profile.getCurrentProfile();
loginSocial(profile.getId(), Const.SOCIAL_FACEBOOK);
}
@Override
public void onCancel() {
}
@Override
public void onError(FacebookException error) {
}
});
public void onActivityResult(int requestCode, int responseCode, Intent data) {
super.onActivityResult(requestCode, responseCode, data);
callbackManager.onActivityResult(requestCode, responseCode, data);
private void loginSocial(String id, String loginType) {
if (!AndyUtils.isNetworkAvailable(activity)) {
AndyUtils.showToast(getResources().getString(R.string.no_internet),
activity);
return;
}
AndyUtils.showCustomProgressDialog(activity,
getResources().getString(R.string.text_signin), false, null);
HashMap<String, String> map = new HashMap<String, String>();
map.put(Const.URL, Const.ServiceType.LOGIN);
map.put(Const.Params.SOCIAL_UNIQUE_ID, id);
map.put(Const.Params.DEVICE_TYPE, Const.DEVICE_TYPE_ANDROID);
map.put(Const.Params.DEVICE_TOKEN,
new PreferenceHelper(activity).getDeviceToken());
map.put(Const.Params.LOGIN_BY, loginType);
new HttpRequester(activity, map, Const.ServiceCode.LOGIN, this);
}
Haben Sie Facebook-App auf dem Telefon installiert? Können Sie das Problem reproduzieren, wenn es nicht installiert ist? –
Ja, Facebook ist auf meinem Gerät installiert – user7108398
Haben Sie sich 'onError (..)' angesehen? –