How to easily share content on a Facebook wall using the Android SDK?

I cannot find many examples of the FB + Android SDK, and the samples are not simple enough (some of them are outdated). My simple goal is to share some content on FB using my Android app. When I developed the iOS app, it's just

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [appDelegate facebookLogin]; NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"pikSpeak", @"name", shareURL, @"link", @"pikSpeak for iPhone !", @"caption", @"Record audio at the moment of the image taken using pikSpeak and feel the moment come alive", @"description", @"shared an audible pic using pikSpeak cam", @"message", imageURL,@"picture", nil]; [[appDelegate facebook] requestWithGraphPath:@"feed" andParams:params andHttpMethod:@"POST" andDelegate:self]; 

This code processed the sessions and saved the session information during application reload.

1) How to just share some things in Android.

2) I saw that Facebook(String app_id) out of date. If so, what is its replacement?

PS: Using Facebook 3.0 SDK

+8
android facebook facebook-graph-api facebook-wall facebook-android-sdk
source share
2 answers

Taken from Share on user’s wall using the Facebook SDK :

 private void share() { Bundle bundle = new Bundle(); bundle.putString("caption", "Harlem Shake Launcher for Android"); bundle.putString("description", "Your android can do the Harlem Shake. Download it from google play"); bundle.putString("link", "https://play.google.com/store/apps/details?id=mobi.shush.harlemlauncher"); bundle.putString("name", "Harlem Shake Launcher"); bundle.putString("picture", "http://shush.mobi/bla.png"); new WebDialog.FeedDialogBuilder(mContext, mySession, bundle).build().show(); } 

If you need to log in (add this to your activity wherever you need to log in / share):

 Session.openActiveSession(this, true, new Session.StatusCallback() { @Override public void call(Session session, SessionState state, Exception exception) { if(session.isOpened()) { share(); } } }); 

You will need to add to your activities:

 @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch(requestCode) { default: if(Session.getActiveSession() != null) //I need to check if this null just to sleep peacefully at night Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data); break; } } 
+18
source share

The feed channel is used to publish on your own wall. From a technical point of view, it is not used. In addition, if you want to achieve sharing functionality, go to the sharing dialog provided by facebook sdk for Android. The Facebook Sharing dialog box provides various functions for friends tags, places, etc. using OpenGraphAction.

0
source share

All Articles