I have installed and configure everything for link The Facebook SDK to my Android App.
- Facebook SDK is in my project
- I added my APP ID in the Facebook APP ID
- My Android Key Hash is correct and linked on the board of Facebook Dev
- I have the Activity "com.facebook.FacebookActivity" in my Manifest
- I have the Activity "com.facebook.LoginActivity" in my Manifest
- I have the meta-data facebook_app_id set in my Manifest and correct
The Facebook widget Login set
<com.facebook.login.widget.LoginButton
android:id="@+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp" />
My Fragment Class
public class FragmentSetting extends android.support.v4.app.Fragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getActivity().getApplicationContext());
SingletonUserData.setCallbackManager(CallbackManager.Factory.create());
}
@Override
public View onCreateView(LayoutInflater inflater,ViewGroup container, Bundle args) {
if (!SingletonUserData.isLogged()) {
view = inflater.inflate(R.layout.fragment_logme, container, false);
TextView facebook = (TextView) view.findViewById(R.id.LogByFacebook);
loginButton = (LoginButton) view.findViewById(R.id.login_button);
loginButton.setReadPermissions(Arrays.asList("public_profile", "user_friends", "email"));
loginButton.setFragment(this);
loginButton.registerCallback(SingletonUserData.getCallbackManager(), new FacebookCallback<LoginResult>() {...});
and
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
SingletonUserData.getCallbackManager().onActivityResult(requestCode, resultCode, data);
}
After several hours, I can't find the error. Is it because of the Fragment? I tried in my MainActivityToFragment but I have always the same backtrace, which is:
Log in attempt failed: LoginActivity could not be started at com.facebook.login.LoginManager.startLogin(LoginManager.java:382) at com.facebook.login.LoginManager.logInWithReadPermissions(LoginManager.java:250) at com.facebook.login.widget.LoginButton$LoginClickListener.onClick(LoginButton.java:689) at com.facebook.FacebookButtonBase$1.onClick(FacebookButtonBase.java:310)