1

I am creating an app. It has a text box and an image box.Once the user filled those out, he clicks "make this a fb post" button. Then I want my app to open facebook mobile app as intent. New "ready to post" post should be created with the text and image. Is this possible to achieve. If yes, can you please let me know the way. If no, is there an alternative way.

bula
  • 8,719
  • 5
  • 27
  • 44
  • Possible duplicate of [android opening facebook app on a specific post](https://stackoverflow.com/questions/14952266/android-opening-facebook-app-on-a-specific-post) – ADM Dec 04 '17 at 07:33

2 Answers2

1

Try this code

File filePath = getFileStreamPath("shareimage.jpg");  //optional. use your image path
         Intent shareIntent = new Intent();
         shareIntent.setAction(Intent.ACTION_SEND);
         shareIntent.putExtra(Intent.EXTRA_TEXT, _text);
         shareIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(new File(filePath)));  //optional//use this when you want to send an image
         shareIntent.setType("image/jpeg");
         shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
         startActivity(Intent.createChooser(shareIntent, "send"))

;

Muhammad Saad
  • 713
  • 1
  • 9
  • 31
1

I recommend you to use Facebooks Share Dialog. So you can achieve your goal in 1 step.

Emre Aktürk
  • 3,306
  • 2
  • 18
  • 30