use of android.webkit.MimeTypeMap in project dropbox-sdk-java by dropbox.
the class FilesActivity method viewFileInExternalApp.
private void viewFileInExternalApp(File result) {
Intent intent = new Intent(Intent.ACTION_VIEW);
MimeTypeMap mime = MimeTypeMap.getSingleton();
String ext = result.getName().substring(result.getName().indexOf(".") + 1);
String type = mime.getMimeTypeFromExtension(ext);
intent.setDataAndType(Uri.fromFile(result), type);
// Check for a handler first to avoid a crash
PackageManager manager = getPackageManager();
List<ResolveInfo> resolveInfo = manager.queryIntentActivities(intent, 0);
if (resolveInfo.size() > 0) {
startActivity(intent);
}
}
Aggregations