Created
January 3, 2012 08:33
-
-
Save btipling/1554096 to your computer and use it in GitHub Desktop.
Opening a file with default app in android
This file contains hidden or 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
try { | |
URL url = file.toURI().toURL(); | |
String ext = MimeTypeMap.getFileExtensionFromUrl(url.toString()); | |
Intent intent = new Intent(); | |
intent.setAction(android.content.Intent.ACTION_VIEW); | |
intent.setDataAndType(Uri.fromFile(file), map.getMimeTypeFromExtension(ext))); | |
startActivity(intent); | |
} catch (Exception e) { | |
Log.e(TAG, "Malformed URL: " + e, e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment