Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 通过Viber和Line等应用程序进行视频共享时出错_Java_Android_Android Intent - Fatal编程技术网

Java 通过Viber和Line等应用程序进行视频共享时出错

Java 通过Viber和Line等应用程序进行视频共享时出错,java,android,android-intent,Java,Android,Android Intent,我想通过以下代码在我的应用程序中共享视频文件: Intent share = new Intent(Intent.ACTION_SEND); Uri uri = Uri.fromFile(path); share.putExtra(Intent.EXTRA_STREAM, uri); share.setType("video/*"); context.startActivity(Intent.createChooser(share, "Share

我想通过以下代码在我的应用程序中共享视频文件:

     Intent share = new Intent(Intent.ACTION_SEND);
     Uri uri = Uri.fromFile(path);
     share.putExtra(Intent.EXTRA_STREAM, uri);
     share.setType("video/*");
     context.startActivity(Intent.createChooser(share, "Share video using"));
它的工作和共享窗口打开,但它的一些应用程序,如Viber和Line我得到错误!Viber表示“所选文件不受支持或似乎已损坏”。但例如WhatsApp可以成功共享视频

它与视频格式无关,因为同一视频可以从Gallery应用程序共享到所有其他应用程序,如Viber、Line和


我怎样才能解决这个问题?我的意图是,像Viber这样的应用程序可以将其检测为有价值的信息进行解析。我也遇到了同样的问题,我通过在视频字符串路径中添加以下前缀来实现这一点:'content://media' 因此,您的代码应该如下所示:

Intent share = new Intent(Intent.ACTION_SEND);
Uri uri = Uri.fromFile("content://media" + path);
share.putExtra(Intent.EXTRA_STREAM, uri);
share.setType("video/*");
context.startActivity(Intent.createChooser(share, "Share video using"));
我希望这能帮到你,因为它帮了我的忙