如何将存储在移动设备上的已录制视频的Uri传递给另一个活动。

huangapple 未分类评论46阅读模式
英文:

How to pass a Uri of a recorded video which is stored in mobile device to another activity

问题

以下是已经翻译好的部分:

我正在尝试将我安卓移动设备中录制的视频的 Uri 传递给 SecondActivity,但是无法获取到这个 Uri。
请提供建议。

MainActivity.java

viewModel.filePaths = new ArrayList<>();
viewModel.filePaths.add(uri);
customDialogBuilder.showLoadingDialog();
Intent intent = new Intent(this, SecondActivity.class);
intent.putExtra("file_content", viewModel.filePaths);
startActivity(intent);

MainViewModel.java

 public List<Uri> filePaths = new ArrayList<>();

SecondActivity.java

viewModel.filePaths = (ArrayList<Uri>) getIntent().getSerializableExtra("file_content");

SecondViewModel.java

public List<Uri> filePaths;

Edit:
实际上,该 URL 是指我从摄像机录制并存储到设备中的视频文件。我想将这个录制的视频路径传递给 SecondActivity,但 UI 上显示为空白屏幕,在第二个 Activity 中值为 null。

英文:

I am trying to pass the Uri of a recorded video from my android mobile device to SecondActivity, but not able to get the uri.
Please suggest.

MainActivity.java

viewModel.filePaths = new ArrayList&lt;&gt;();
viewModel.filePaths.add(uri);
customDialogBuilder.showLoadingDialog();
Intent intent = new Intent(this, SecondActivity.class);
intent.putExtra(&quot;file_content&quot;, viewModel.filePaths);
startActivity(intent);

MainViewModel.java

 public List&lt;Uri&gt; filePaths = new ArrayList&lt;&gt;();

SecondActivity.java

viewModel.filePaths = (ArrayList&lt;Uri&gt;) getIntent().getSerializableExtra(&quot;file_content&quot;);

SecondViewModel.java

public List&lt;Uri&gt; filePaths;

Edit :
Actually the Url is for a Video file which I have recorded from camera and store to my device. I want to pass this recorded video path to SecondActivity, but it's showing blank screen on UI and null values in 2nd Activity

huangapple
  • 本文由 发表于 2020年7月24日 19:06:10
  • 转载请务必保留本文链接:https://java.coder-hub.com/63072309.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定