Android打算用原始资源打开视频吗? [英] Android intent to open video with raw resource?
问题描述
有人知道我可以用来在手机的视频播放器中打开原始mp4资源的意图吗?我尝试了这段代码:
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);
这引发了ActivityNotFoundException,但是当URI是sdcard且视频位于此处时,这对我有用.有谁知道我如何在我的应用程序中将上述代码与资源文件一起使用?
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?
推荐答案
其他应用无法访问您的资源.您需要创建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).
这篇关于Android打算用原始资源打开视频吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!