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).
精彩评论