0

I would like my facebook login button to automatically grab the user's facebook information and create a profile from it.

I have looked at the example provided by facebook, but I don't want to create separate fragments in a LinearLayout. I would just like to implement it into my RelativeLayout.

Can someone advise me on what to do? I searched everywhere and found deprecated answers and am new to the Facebook API :/

What method would I need to create to grab the user's information, and then send that information to a second activity class?

Here is some of the code I've written so far:

package com.example.app;

import com.facebook.*;
import com.facebook.model.GraphUser;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

public class MainActivity extends Activity {    

@Override
/*
 * called when activity is first created
 */
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

/*
 * Create API call to facebook to grab user data and define a 
 * new callback to handle the response
 */
public void GrabFbUserInfo(View view){


    //Request call
    Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {

        @Override
        public void onCompleted(GraphUser user, Response response) {
            //If the response is successful
            if (session == Session.)

        }
    });

}

}

Here is the XML for activity_main which is contained inside RelativeLayout:

<com.facebook.widget.LoginButton
    android:id="@+id/fb_login_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="76dp"
    android:contentDescription="@string/loginButton"
    facebook:confirm_logout="false"
    facebook:fetch_user_info="true" />

Appreciate any advice!

AndyRoid
  • 5,062
  • 8
  • 38
  • 73
  • Follow my post http://stackoverflow.com/questions/23543822/facebook-friend-picker-sdk-sample-not-working-android – Chandru May 18 '14 at 07:29

1 Answers1

0

Please try my library: https://github.com/antonkrasov/AndroidSocialNetworks

With it's help it's really easy task.

mSocialNetworkManager.getFacebookSocialNetwork().requestLogin(new OnLoginCompleteListener() {
    @Override
    public void onLoginSuccess(int socialNetworkID) {
        mSocialNetworkManager.getFacebookSocialNetwork().requestCurrentSocialPerson();
    }

    @Override
    public void onError(int socialNetworkID, String requestID, String errorMessage, Object data) {

    }
});

Check README for more info, please let me know if you will have any issues.

Anton Krasov
  • 124
  • 1
  • 5
  • Hi Anton, first of all brilliant work. Secondly I am fairly new to android programming how would I go about adding your library to my existing project? Is it similar to adding the facebook SDK to my existing project? – AndyRoid May 18 '14 at 21:25
  • @AndyRoid, Hi, please follow this [Getting Started](https://github.com/antonkrasov/AndroidSocialNetworks#getting-started) – Anton Krasov May 19 '14 at 05:56