Android 打算用原始资源打开视频吗?
有谁知道我可以用来在手机视频播放器中打开原始 mp4 资源的意图?我尝试了这段代码:
Uri video = Uri.parse( "android.resource://" + getPackageName() + "/" + R.raw.video );
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(video, "video/*");
startActivity(intent);
这引发了 ActivityNotFoundException,但是当 URI 是 sdcard 并且视频位于那里时,这对我有用。有谁知道如何在我的应用程序中将上述代码与资源文件一起使用?
Does anyone know of an intent I can use to open a raw mp4 resource in the phone's video player? I tried this code:
Uri video = Uri.parse( "android.resource://" + getPackageName() + "/" + R.raw.video );
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(video, "video/*");
startActivity(intent);
This threw an ActivityNotFoundException, however this has worked for me when the URI was the sdcard and the video was located there. Does anyone know how I can use the above code with a resource file in my app?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
其他应用程序无法访问您的资源。您需要创建一个 ContentProvider,或将数据存储在任何人都可以访问的位置(SD 卡或本地存储中的公共文件夹中)。
Other apps can't access your resources. You'll need to create a ContentProvider, or store the data in a place accessible to anyone (either SD card, or in a public folder in your local storage).