Android intent to open video with raw resource?

2019-01-28 12:00发布

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?

1条回答
倾城 Initia
2楼-- · 2019-01-28 12:15

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

查看更多
登录 后发表回答