Using ActionChooser with an Email and Facebook Android Application

I am trying to create a “publish” button for an image in my Android application that works with a Facebook application and email.

This is my code (imagePath is something like "/sdcard/myapp/image.jpg"

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/jpeg");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+imagePath));

sendIntent.putExtra(Intent.EXTRA_TEXT, "Enjoy the photo");
startActivity(Intent.createChooser(sendIntent, "Email:"));

This works great for sending email with the app, but it doesn't work with the Facebook app. If i use

    sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(imagePath));

Facebook posting works, but email attachment is no longer sent.

Any ideas what can be done for both?

+3
source share
5 answers

If someone is interested ... I solved this indirectly:

    File imageFile = new File(imagePath);
    String url = "";
    try {
         url = Media.insertImage(getContentResolver(), imageFile.getAbsolutePath(), imageFile.getName(), imageFile.getName());
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
+2
source

mseo , () facebook !

mseo- Gmail Facebook. , Facebook ( FB, , FB), Blogger, Wordpress, Twitter, Dropbox ..

: , :

sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(imageFile));

: Dropbox. Facebook ( Android Facebook), - SD- Facebook. , , , ​​ Facebook. , , .

+1

, gmail, txt facebook.

Intent sendIntent = Intent (Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, "" ); sendIntent.setType( "/" ); startActivity (Intent.createChooser(sendIntent, " " ));

, , gmail . facebook ?

0

Facebook URL . ,

sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(imagePath));

. url facebook - .

0

Source: https://habr.com/ru/post/1769927/


All Articles