Android intends to open a video with a raw resource?

Does anyone know of an intention that I can use to open the mp4 source resource in a phone 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 it worked for me when the URI was an SD card and the video was there. Does anyone know how I can use the above code with a resource file in my application?

+3
source share
1 answer

Other applications cannot access your resources. You will need to create a ContentProvider or save the data in an accessible place for everyone (SD card or in a shared folder in your local storage).

+5

Source: https://habr.com/ru/post/1773978/


All Articles