【问题标题】:how to share text+video in single intent in android?如何在android中以单一意图共享文本+视频?
【发布时间】:2018-08-08 04:11:27
【问题描述】:

在此代码下方,我尝试与视频共享文本,但它仅共享视频,文本不与视频共享。

如果有人能解决我的问题,请帮忙。

String path="android.resource://" + "com.avani.videoviewdemo" + "/" + R.raw.ae_kaash_kahi;
 //Intent a = getIntent(); 
file=new File(path); 
str=arrayList.get(position).getVideoName(); 
Log.e("video_name", ""+arrayList.get(position).getVideoName()); Log.e("video_name",""+ str); 
id = context.getResources().getIdentifier(str, "raw", context.getPackageName()); Uri uri = Uri.parse("android.resource://" + context.getPackageName() + "/" + id);
 DownloadFile(); 
Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
Uri screenshotUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider", file); sharingIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri); sharingIntent.putExtra(Intent.EXTRA_TEXT, "From FullScreenVideoStatus"); sharingIntent.setType("video/*"); context.startActivity(Intent.createChooser(sharingIntent, "Share video using"));

【问题讨论】:

标签: android share


【解决方案1】:

要在分享意图的视频/图像中设置标题,只需在以下位置设置文本:

sharingIntent.putExtra(Intent.EXTRA_TITLE, "Your text caption");

【讨论】:

    【解决方案2】:
    Intent sharingIntent = new Intent(Intent.ACTION_SEND);
    sharingIntent.setType("video/mp4"); //If it is a 3gp video use ("video/3gp")
    Uri uri = Uri.parse("android.resource://" + getPackageName() + "/raw/ae_kaash_kahi";
    sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);
    sharingIntent.putExtra(Intent.EXTRA_TEXT, "Video Title");
    startActivity(Intent.createChooser(sharingIntent, "Share Video!"));
    

    【讨论】:

      【解决方案3】:
              intent = new Intent(Intent.ACTION_SEND);
              intent.putExtra(Intent.EXTRA_TEXT, "TEMPORARY"); // for text share
              intent.putExtra(Intent.EXTRA_STREAM, uri); // for media share
              intent.setType("image/*"); // this line is use to filter which app support specified media formate to share
              startActivity(intent);
      

      您可以在这里使用 video/* 作为视频文件我使用 image/* 进行图像共享

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-04-15
        • 2012-02-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多