它已经为这个问题挣扎了5天,仍然没有得到任何有效的解决方案。终于想到了从这里的天才那里得到帮助。问题:我正试图从图库中挑选一段视频(但在某些平板电脑设备版本28中(,但出现了上述异常。我想声明的是,有些是亚马逊平板电脑,所以我不确定是否需要对此进行任何具体检查。以下是我的代码:
private fun selectVideo() {
val items = arrayOf<CharSequence>("Camera", "Gallery", "Cancel")
val builder = AlertDialog.Builder(this)
builder.setTitle("Add Attachment")
builder.setItems(items) { dialog, item ->
if (items[item] == "Camera") {
val videoCaptureIntent = Intent(MediaStore.ACTION_VIDEO_CAPTURE)
videoCaptureIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 20);
if (videoCaptureIntent.resolveActivity(packageManager) != null) {
startActivityForResult(videoCaptureIntent, REQUEST_VIDEO_CAPTURE)
}
} else if (items[item] == "Gallery") {
val galleryIntent = Intent(
Intent.ACTION_PICK,
android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI
)
startActivityForResult(galleryIntent, REQUEST_VIDEO_PICK)
}
}
}
builder.show()
}
非常感谢您的支持。
尝试以下代码
var intent = new Intent ();
intent.SetType ("video/*");
intent.SetAction (Intent.ActionGetContent);
intent.PutExtra (MediaStore.ExtraVideoQuality, 0);
intent.PutExtra (MediaStore.ExtraDurationLimit, Globals.VideoMaxDuration);
this.StartActivityForResult (Intent.CreateChooser (intent, "Select video"), 200);