ITeye博客

Android调用本机程序执行文件的方法

fonter · 2010-06-24 13:18 · android · 移动开发 · Markdown

有时需要用运行文件,如MP3,MP4等,可用下面的方法调用本机程序来执行它

 

 

	Intent intent = new Intent(Intent.ACTION_VIEW);
	Uri uri = Uri.parse("file://"+info.getFile().getPath()); 
	String type = null;
	try {
		type = MimeTypeMap.getSingleton()
		.getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(info.getFile().getCanonicalPath()));
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	if(type!=null){
		//intent.setType(type);
		intent.setDataAndType(uri, type);
		startActivityForResult(intent, 1);
	}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。