Robert Smith
Robert Smith

Reputation: 457

How to access news feed section of facebook in Android?

I can connect to my application in Facebook. I am trying to fetch news feed of application in Facebook.

After login it prompts me if it can 'access posts in my news feed', allow or don't allow. If I click on allow then nothing happens. It just goes back to my activity screen. I am new totally.

Why can't I access news feed section of that application in facebook?

The code is given below:

public class MyGreatActivity extends Activity 
 {
    Facebook facebook = new Facebook("115793565149113"); 
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {  
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main); 
        facebook.authorize(this, new String[] {"read_stream" }, 
        new DialogListener() { 
        @Override
        public void onComplete(Bundle values) {}
        @Override
        public void onFacebookError(FacebookError error) {} 

        @Override
        public void onError(DialogError e) {} 

        @Override
        public void onCancel() {} 
    });

}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) { 
    super.onActivityResult(requestCode, resultCode, data);

    facebook.authorizeCallback(requestCode, resultCode, data); 
}

}

Upvotes: 1

Views: 1426

Answers (1)

THelper
THelper

Reputation: 15619

What you've done so far is just setting up the connection. Now you need to make a request to actually get the data you want.

Add something like this to your code.

AsyncFacebookRunner fbData = new AsyncFacebookRunner(facebook);
Bundle params = new Bundle();
// what data should be retrieved       
params.putString("fields", "type, link, from, message, picture, name, description, created_time");
// from which feed would you like data 
fbData.request("yourappname/feed", params, new FBRequestListener(this));

// class that will handle the data from facebook
public class FBRequestListener implements RequestListener {
....    // check the documentation on which methods you should include
}

Upvotes: 1

Related Questions