title: Android Facebook Integration - Predefined Wall Post
body: <p>I want to add functionality to my app where a user can share with their friends that they are using my app. I want the post to have a predefined message, but all I can get working is a regular post from my app. Is there anyway I can do this and maybe with an image as well. but that's not as important.. Any ideas?</p>
  
  <p>Here's where I handle everything with Facebook (Logging in AND Posting):</p>
  
  <pre><code>public class FacebookSSO extends Activity {
  
  Facebook facebook = new Facebook("APP_ID");
  private SharedPreferences mPrefs;
  private static final String TAG = "FacebookConnect";
  private static final String MSG = "Signed In Using MNWV For Android - Check It Out!";    
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      /*
       * Get existing access_token if any
       */
      mPrefs = getPreferences(MODE_PRIVATE);
      String access_token = mPrefs.getString("access_token", null);
      long expires = mPrefs.getLong("access_expires", 0);
      if(access_token != null) {
          facebook.setAccessToken(access_token);
      }
      if(expires != 0) {
          facebook.setAccessExpires(expires);
      }
  
      /*
       * Only call authorize if the access_token has expired.
       */
      if(!facebook.isSessionValid()) {
  
              facebook.dialog(this, "oauth", new DialogListener() {
            @Override
            public void onComplete(Bundle values) {  
                SharedPreferences.Editor editor = mPrefs.edit();
                editor.putString("access_token", facebook.getAccessToken());
                editor.putLong("access_expires", facebook.getAccessExpires());
                editor.commit();                       
                Bundle parameters = new Bundle();
                parameters.putString(TAG, MSG);// the message to post to the wall                    
  
                facebook.dialog(FacebookSSO.this, "stream.publish", parameters, new DialogListener() { 
                    @Override
                  public void onComplete(Bundle values) {  
                      SharedPreferences.Editor editor = mPrefs.edit();
                      editor.putString("access_token", facebook.getAccessToken());
                      editor.putLong("access_expires", facebook.getAccessExpires());
                      editor.commit();  
  
                         Intent in = new Intent(FacebookSSO.this, MNWVMainScreen.class);
                           startActivity(in);
                  }
  
                  @Override
                  public void onFacebookError(FacebookError error) {}
  
                  @Override
                  public void onError(DialogError e) {}
  
                  @Override
                  public void onCancel() {}
  
                });
            }
  
            @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);
  }
  }
  </code></pre>