Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to link parse.com to facebook

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

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 by: Log in attempt failed: FacebookActivity could not be started. Please make sure you added FacebookActivity to the AndroidManifest. There is no page redirect to login of facebook. What is wrong in the above code?

Thanks!

like image 227
pearmak Avatar asked Nov 29 '22 14:11

pearmak


1 Answers

You have not included the activity for Facebook login 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" />

Refer Facebook Android SDK for more information.

like image 142
Hashan Seneviratne Avatar answered Dec 04 '22 15:12

Hashan Seneviratne