我正在尝试从我的存储中获取媒体文件并通过 action_view 意图播放它。它保存在缓存中。我的代码如下所示:
@Override
public void onClick(View arg0) {
Intent viewMediaIntent = new Intent();
viewMediaIntent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File(prefs.getAssetDir() + "/" + poi.getRoute().getId() + "/"
+ poiMedia.getContentMedia().getMedia().getFileName());
Log.w("Karl",file.exists()+" < File exists");
// returns true
viewMediaIntent.setDataAndType(Uri.fromFile(file), "video/*");
viewMediaIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(viewMediaIntent);
}
};
我得到的错误是权限被拒绝错误。我已经在清单中获得了用户权限 WRITE_EXTERNAL_STORAGE。
有人能帮助我吗?
编辑:
日志猫:
Failed to open file '/data/data/nl.kloeg.beleefroutes/cache/beleefRoutes/com.burokloeg.beleefroutes.0210OpPadMetRembrandt1/38669.mp4'. (Permission denied)
E/AwesomePlayer(1931): cannot create dataSource
W/AwesomePlayer(1931): onPrepareAsyncEvent() finishSetDataSource_l error(-2147483648)
W/AwesomePlayer(1931): abortPrepare() mIsAsyncPrepare (1), err (-2147483648)