0

I am trying to take a look on the Facebook SDK for android, and I have created a new empty project, which the AndroidManifest.xml looks like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.test.facebook_test"
          xmlns:android="http://schemas.android.com/apk/res/android">

    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:name=".TestApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>

        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <activity android:name="com.facebook.FacebookActivity"
                  android:configChanges=
                      "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
                  android:theme="@android:style/Theme.Translucent.NoTitleBar"
                  android:label="@string/app_name" >

        </activity>

    </application>

</manifest>

And my MainActivity looks like this:

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Intent intent = new Intent(MainActivity.this,com.facebook.FacebookActivity.class);
        startActivity(intent);
    }
}

However, the Facebook activity can never be launched, with the error:

E/LoginFragment: Cannot call LoginFragment with a null calling package. This can occur if the launchMode of the caller is singleInstance.

By looking through other threads on stackoverflow, I learnt that having android:launchMode="singleTask" would cause this problem, but my problem here is that I didn't set any of the activity to be android:launchMode="singleTask" in the manifest at all.

So what would be the problem here? And how to fix it?

passer
  • 634
  • 2
  • 8
  • 16
  • Where you init Facebook SDK like this: `FacebookSdk.sdkInitialize(getApplicationContext());`? – pRaNaY Feb 02 '16 at 04:26
  • Need to check [this](http://stackoverflow.com/questions/14123580/updated-android-facebook-api-3-0-error-cannot-call-loginactivity-with-a-null) – pRaNaY Feb 02 '16 at 04:32
  • Before you start anything handson on Facebook sdk, just clear your concepts about it. A solution for the same is mentioned here with links. If you you want to know in depth about it, give it a try:https://stackoverflow.com/questions/34101848/facebook-login-for-android-getting-error-for-the-second-login/34101957#34101957 – Yogesh Patel Feb 02 '16 at 04:39
  • @pRaNaY I did that in the custom application class onCreate() – passer Feb 02 '16 at 05:04
  • 1
    What are you trying to do and why are you launching the FacebookActivity directly? The FacebookActivity is not meant to be launched directly, the SDK invokes it indirectly when do you things like login, or share. It also needs to be called with startActivityForResult rather than startActivity, which is why you're seeing this error. – Ming Li Feb 05 '16 at 23:10

0 Answers0