Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I figured it out, with Tom's help (thanks). The key was creating a dialog with the "stream.publish" API call, using the Facebook Android SDK. Here are the steps:</p> <ol> <li>Download the official Facebook Android SDK : <a href="http://github.com/facebook/facebook-android-sdk" rel="noreferrer">http://github.com/facebook/facebook-android-sdk</a></li> <li>Import the project files into Eclipse.</li> <li><p>Export the project as a *.jar file. (this might cause a conflict)</p> <p><strong>[UPDATE]</strong></p> <p>Facebook recently updated the source code and I noticed the icon file caused resource id conflicts with my projects (Android 1.5+). My solution is to forget about exporting as a jar. Instead, copy the Facebook "com" folder directly into your app's "src" folder (i.e. "com.facebook.android" should be a package in your app... right alongside your source files). If you already have a "com" folder in your "src" folder, don't worry about any dialog boxes that appear about overwriting files, none of your source files should be overwritten. Go back into Eclipse, and refresh the "src" folder and "com.facebook.android" should now be listed as a package. Copy one of the included Facebook icons to your app's "drawable" folder and refresh that as well. Eclipse will complain about the "FbDialog.java" file... just add an import pointing to your app's "R" file to the header of that file (e.g. if your app's package name is "com.android.myapp," then add this: "import com.android.myapp.R;"). Go to #5 if you needed to do this.</p></li> <li><p>Add the .jar file to your project's build path</p></li> <li>Look at the following simplified example code:</li> </ol> <pre> <code> import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.LinearLayout; import com.facebook.android.*; import com.facebook.android.Facebook.DialogListener; public class FacebookActivity extends Activity implements DialogListener, OnClickListener { private Facebook facebookClient; private LinearLayout facebookButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.test);//my layout xml facebookButton = (LinearLayout)this.findViewById(R.id.Test_Facebook_Layout); } @Override public void onComplete(Bundle values) { if (values.isEmpty()) { //"skip" clicked ? return; } // if facebookClient.authorize(...) was successful, this runs // this also runs after successful post // after posting, "post_id" is added to the values bundle // I use that to differentiate between a call from // faceBook.authorize(...) and a call from a successful post // is there a better way of doing this? if (!values.containsKey("post_id")) { try { Bundle parameters = new Bundle(); parameters.putString("message", "this is a test");// the message to post to the wall facebookClient.dialog(this, "stream.publish", parameters, this);// "stream.publish" is an API call } catch (Exception e) { // TODO: handle exception System.out.println(e.getMessage()); } } } @Override public void onError(DialogError e) { System.out.println("Error: " + e.getMessage()); } @Override public void onFacebookError(FacebookError e) { System.out.println("Error: " + e.getMessage()); } @Override public void onCancel() { } @Override public void onClick(View v) { if (v == facebookButton) { facebookClient = new Facebook(); // replace APP_API_ID with your own facebookClient.authorize(this, APP_API_ID, new String[] {"publish_stream", "read_stream", "offline_access"}, this); } } } </code> </pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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