Created
October 18, 2012 07:44
-
-
Save jiemachina/3910321 to your computer and use it in GitHub Desktop.
根据文件路径,使用默认程序打开
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW); | |
File file = new File(sdcardPath); | |
String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(Uri.fromFile(file).toString()); | |
String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); | |
myIntent.setDataAndType(Uri.fromFile(file),mimetype); | |
mContext.startActivity(myIntent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment