调用已安装视频播放器播放未修改之前的代码
private void startPlay(String fileName){ File file = new File(fileName); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); String type = "video/*"; Uri uri = Uri.parse(file.getAbsolutePath()); intent.setDataAndType(uri, type); startActivity(intent);}
在三星的一台4.2的手机上测试没有问题,但是在小米系列手机上,无法启动播放器,做如下修改后,所有手机上正常
private void startPlay(String fileName){ // File file = new File(fileName); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); String type = "video/*"; Uri uri = Uri.parse("file://" + fileName);//-----modify here intent.setDataAndType(uri, type); startActivity(intent);}