使用共享意图android共享文本和图像中的问题

使用共享意图android共享文本和图像中的问题,android,facebook,android-intent,Android,Facebook,Android Intent,朋友们好,我想在android中使用share intent同时共享文本和SD卡图像,下面是我的代码,点击按钮 Intent share = new Intent(android.content.Intent.ACTION_SEND); share.setType("text/plain,image/*"); String imagePath = Environment.getExternalStorageDirectory() + "/myfol

朋友们好,我想在android中使用share intent同时共享文本和SD卡图像,下面是我的代码,点击按钮

    Intent share = new Intent(android.content.Intent.ACTION_SEND);
    share.setType("text/plain,image/*");
    String imagePath = Environment.getExternalStorageDirectory()
            + "/myfolder/1407156604780.png";
    File imageFileToShare = new File(imagePath);
    Uri uri = Uri.fromFile(imageFileToShare);
    share.putExtra(Intent.EXTRA_STREAM, uri);
    share.putExtra(Intent.EXTRA_SUBJECT, "Title Of The Post");
    share.putExtra(Intent.EXTRA_TEXT, "fdsfdsfdsfds");
    startActivity(Intent.createChooser(share, "Share image to..."));

“使用上述代码共享”对话框已打开,但facebook选项未向我显示,但在我的设备上,facebook应用程序已经存在,因此我可以为facebook设置文本和图像共享的多个setType属性吗?

首先,facebook不允许使用共享意图共享文本,我们需要使用facebook sdk。除facebook和instagram之外的所有其他社交媒体都支持以下代码。但你可以在poopup dilog中看到facebook和所有其他已安装的应用程序

      Intent shareIntent = new Intent();
            shareIntent.setAction(Intent.ACTION_SEND);
            shareIntent.setType("text/plain");
            shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
            shareIntent.putExtra(Intent.EXTRA_TEXT, "text");
            shareIntent.putExtra(Intent.EXTRA_STREAM, image);
            shareIntent.setType("image/*");
            // Launch sharing dialog for image
            startActivity(Intent.createChooser(shareIntent, "Share"));

尝试一下..

当你们在fab上分享你们在对话框中看到的东西时,试一下分享。setTypetext/plain;除了那一行之外,我的代码看起来是一样的,而且运行良好。。这会对你有很大帮助。嗨,我已经尝试过了,但是使用intent你不能共享文本默认值你只能共享文本的图像你必须在对话框显示后手动输入文本twitte是允许的,但facebook是不允许的默认文本@Born to Win:当我使用setType/和shre与facebook选项时,它会给我祝酒词,如please attach only照片或单个视频