Share text and Image together using Facebook SDK in Android

I'm using facebook SDK for share text and image in Android.I have used following code and its working for share text but how to share image together.I'm so confused about this.If any know please suggest me.

Code:

public class MainActivity extends Activity {

Facebook facebook = new Facebook("App ID");
EditText edittext;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    edittext = (EditText) findViewById(R.id.revieew);

    facebook.authorize(this, new DialogListener() {
        @Override
        public void onComplete(Bundle values) {
        }

        @Override
        public void onFacebookError(FacebookError error) {
        }

        @Override
        public void onError(DialogError e) {
        }

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

public void share(View v) {
    //facebook.dialog(this, "feed", new PostDialogListener());

    Bundle parameters = new Bundle();
    // parameters.putString("message", category_item_name_desc.getText()
    // .toString());
    // parameters.putString("picture", categoryItemsModel.getImageUrl());
    parameters.putString("caption", edittext.getText().toString());
    try {
        facebook.request("/me/feed", parameters, "POST");
        System.out
                .println("**********************POST**********************************");
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

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

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

} And also i don't want to show dialog for share image and text i want to use Edittext and button for that...

Answers


Hey this code might be helpful,

Bundle parameters = new Bundle();
                parameters.putString("message", category_item_name_desc.getText().toString());
                parameters.putString("picture", categoryItemsModel.getImageUrl());
                parameters.putString("caption", txtDescription_desc.getText().toString());
                facebook.request("/me/feed", parameters, "POST");

You can add text by adding paramater as "caption"


Need Your Help

Objective-C preprocessor available?

c objective-c compiler-construction

Does anyone know if the source code for Objective-C is still available from when it was just a pre-processor? Would be curious to see how it was implemented back then.

Email notification on success/failed build using ant target

unit-testing ant build build-process build-automation

my current code(build.xml) enables me to send email on successful build, but when failed, nothing happens. The targets are called from a build.bat file through command similar to " ........ -