Skip to content

Instantly share code, notes, and snippets.

@jiemachina
Created October 18, 2012 07:44
Show Gist options
  • Save jiemachina/3910321 to your computer and use it in GitHub Desktop.
Save jiemachina/3910321 to your computer and use it in GitHub Desktop.
根据文件路径,使用默认程序打开
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