Android: how to link parse.com to facebook

I am working on ParseFacebookUser. From the documentation, I encoded the facebook login module as follows:

the code:

@Override  
    protected void onResume() 
    {  
        super.onResume();  
        ....

        Parse.initialize(this, "XXX", "XXX"); 
        ParseFacebookUtils.initialize(this);

        // FB: Logs 'install' and 'app activate' App Events.
        AppEventsLogger.activateApp(this);

        List<String> permissions = Arrays.asList("user_birthday", "user_location", "user_friends", "email", "public_profile");
        ParseFacebookUtils.logInWithReadPermissionsInBackground(this, permissions, new LogInCallback() 
        {
              @Override
              public void done(ParseUser user, ParseException err) 
              {
                    if (user == null) 
                    {
                        Log.d("MyApp","Uh oh. The user cancelled the Facebook login.");
                    } 
                    else if (user.isNew()) 
                    {
                        Log.d("MyApp", "User signed up and logged in through Facebook!");
                    } 
                    else 
                    {
                        Log.d("MyApp", "User logged in through Facebook!");
                    }
              }
        });


    }

manifest:

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/MyTheme" >
        <activity
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <activity android:name="com.abc.user.LoginActivity"             android:screenOrientation="portrait"/>
        <activity android:name="com.abc.user.RegisterActivity"              android:screenOrientation="portrait"/>
        <activity android:name="com.abc.user.User_leaderboard"              android:screenOrientation="portrait"/>   
        <activity android:name="com.facebook.LoginActivity" 
                        android:theme="@android:style/Theme.Translucent.NoTitleBar" android:label="@string/app_name" /> />

        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>   

    </application>

Logcat:

07-12 01:13:57.488: E/AndroidRuntime(23542): Caused by: Log in attempt failed: FacebookActivity could not be started. Please make sure you added FacebookActivity to the AndroidManifest.
07-12 01:13:57.488: E/AndroidRuntime(23542):    at com.facebook.login.LoginManager.startLogin(LoginManager.java:381)
07-12 01:13:57.488: E/AndroidRuntime(23542):    at com.facebook.login.LoginManager.logInWithReadPermissions(LoginManager.java:261)
07-12 01:13:57.488: E/AndroidRuntime(23542):    at com.parse.FacebookAuthenticationProvider.authenticateAsync(FacebookAuthenticationProvider.java:155)
07-12 01:13:57.488: E/AndroidRuntime(23542):    at com.parse.ParseAuthenticationProvider.logInAsync(ParseAuthenticationProvider.java:50)
07-12 01:13:57.488: E/AndroidRuntime(23542):    at com.parse.ParseFacebookUtils.logInAsync(ParseFacebookUtils.java:265)
07-12 01:13:57.488: E/AndroidRuntime(23542):    at com.parse.ParseFacebookUtils.logInWithReadPermissionsInBackground(ParseFacebookUtils.java:161)
07-12 01:13:57.488: E/AndroidRuntime(23542):    at com.parse.ParseFacebookUtils.logInWithReadPermissionsInBackground(ParseFacebookUtils.java:173)
07-12 01:13:57.488: E/AndroidRuntime(23542):    at com.abc.abc.First.onResume(First.java:144)
07-12 01:13:57.488: E/AndroidRuntime(23542):    at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1210)
07-12 01:13:57.488: E/AndroidRuntime(23542):    at android.app.Activity.performResume(Activity.java:5512)
07-12 01:13:57.488: E/AndroidRuntime(23542):    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2948)
07-12 01:13:57.488: E/AndroidRuntime(23542):    ... 12 more

Question:

Caused: Login error: Failed to start the FacebookActivity function. Please make sure you add FacebookActivity to AndroidManifest. No page redirect to facebook login. What is wrong with the above code?

Thank!

+4
source share
1 answer

You have not enabled Facebook login activity in the manifest file. Add this.

<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" />

See the Android Android SDK for more details .

+23
source

All Articles