Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have the solution that might help you, I am using this for my code and its working fine..</p> <p>private void publishFeedDialog(String friend_uid) {</p> <pre><code> try{ Session mCurrentSession = Session.getActiveSession(); SessionTracker mSessionTracker = new SessionTracker( getBaseContext(), new StatusCallback() { public void call(Session session, SessionState state, Exception exception) { } }, null, false); String applicationId = Utility .getMetadataApplicationId(getBaseContext()); mCurrentSession = mSessionTracker.getSession(); if (mCurrentSession == null || mCurrentSession.getState().isClosed()) { mSessionTracker.setSession(null); Session session = new Session.Builder(getBaseContext()) .setApplicationId(applicationId).build(); Session.setActiveSession(session); mCurrentSession = session; } if (!mCurrentSession.isOpened()) { Session.OpenRequest openRequest = null; openRequest = new Session.OpenRequest( NewFriendList.this); if (openRequest != null) { openRequest .setDefaultAudience(SessionDefaultAudience.FRIENDS); openRequest.setPermissions(Arrays.asList("email", "publish_actions")); openRequest .setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO); mCurrentSession.openForPublish(openRequest); } } if (regobj != null &amp;&amp; friend_uid != null ) { final Activity activity = this; Bundle params = new Bundle(); //This is what you need to post to a friend's wall params.putString("from", "" + regobj.MyFBID); params.putString("to", friend_uid); //up to this params.putString("name", "Facebook SDK for Android"); params.putString("caption", "Build great social apps and get more installs."); params.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps."); params.putString("link", "https://developers.facebook.com/android"); params.putString("picture", "https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png"); WebDialog feedDialog = (new WebDialog.FeedDialogBuilder(this, mCurrentSession, params)) .setOnCompleteListener(new OnCompleteListener() { @Override public void onComplete(Bundle values, FacebookException error) { if (error == null) { // When the story is posted, echo the success // and the post Id. final String postId = values.getString("post_id"); if (postId != null) { Toast.makeText(activity, "Posted story, id: "+postId, Toast.LENGTH_SHORT).show(); } else { // User clicked the Cancel button Toast.makeText(activity, "Publish cancelled", Toast.LENGTH_SHORT).show(); } } else if (error instanceof FacebookOperationCanceledException) { // User clicked the "x" button Toast.makeText(activity, "Publish cancelled", Toast.LENGTH_SHORT).show(); } else { // Generic, ex: network error Toast.makeText(activity, "Error posting story", Toast.LENGTH_SHORT).show(); } } }).build(); feedDialog.show(); } }catch(Exception e) { Log.d("Error", ""+e.toString()); } } </code></pre> <p>This code will work for only one user, if you want to send it to multiple user then you can use RequestsDialogBuilder instead of WebDialog.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload