开发者

Android intent to open video with raw resource?

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.se开发者_如何转开发tDataAndType(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?


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜