我无法导航到selectedVideo屏幕,也无法在屏幕中显示视频。
val intent = Intent(Intent.ACTION_PICK, null)
intent.type = "video/*"
resultLauncher.launch(intent)
private val resultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == RESULT_OK) {
val data: Intent? = result.data
// For null safety, make sure data is not null
if (data == null) {
Log.d("TAG", "Data returned is null")
return@registerForActivityResult
}
val videoUri: Uri = data?.data!!
val videoPath = parsePath(videoUri)
if (videoPath != null) {
Log.d("videoPath", videoPath)
val intent = Intent(requireActivity(), SelectVideoActivity::class.java)
intent.putExtra("path", videoUri.path)
startActivity(intent)
Log.i("selectedMediaList", videoUri.isAbsolute.toString())
}
}
}
字符串
错误日志:
java.lang.SecurityException: UID 10170 does not have permission to content://com.google.android.apps.photos.contentprovider/-1/2/content%3A%2F%2Fmedia%2Fexternal%2Fvideo%2Fmedia%2F25/ORIGINAL/NONE/video%2Fmp4/1574077794 [user 0] at android.os.Parcel.createExceptionOrNull
型
1条答案
按热度按时间qc6wkl3g1#
替换:
字符串
使用:
型
在
SelectVideoActivity
中,对Intent
使用getData()
来检索Uri
。this blog post of mine更多
更好的方法是只使用一个Activity,并在单独的屏幕上使用片段或组合。