0

I'm trying to add Facebook Login to my app and have encountered an odd issue. This is the code for my FacebookActivity, which is started by an intent from the main activity

public class  FacebookLoginActivity2 extends FacebookActivity {

    private LoginButton loginButton;
    private CallbackManager callbackManager;

    @Override
    public   void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        FacebookSdk.sdkInitialize(getApplicationContext());
        setContentView(R.layout.activity_facebook_login_activity2);
        loginButton = (LoginButton)findViewById(R.id.login_button);

        callbackManager = CallbackManager.Factory.create();
        loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {...})

The inflated XML file "activity_facebook_login_activity2" contains a LoginButton widget with the id set to "login_button". This is the file.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="match_parent"
    android:padding="16dp"
    android:id="@+id/login_parent"
    >
    <com.facebook.login.widget.LoginButton
        android:id="@+id/login_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
    />

</RelativeLayout>

Logcat says the error is

java.lang.IllegalArgumentException: No view found for id 0x7f0d007c (com.example.nopony.swipedviews:id/com_facebook_fragment_container) for fragment LoginFragment{424aa3e8 #0 id=0x7f0d007c SingleFragment}

But I don't even know what view is it looking for that it cannot find. Please excuse the massive paste, I am utterly lost.

Bacteria
  • 8,406
  • 10
  • 50
  • 67
chmod777
  • 56
  • 4

1 Answers1

0

You shouldn't extend from FacebookActivity. Use base classes from the Android SDK, e.g. FragmentActivity:

public class FacebookLoginActivity2 extends FragmentActivity {
    // your custom implementation comes here
}
gabhor
  • 669
  • 9
  • 23