Launching an intent for file and MIME type?

Well thanks to the Open Intent guys, I missed the answer the first time through their code in their file manager, here’s what I ended up with: File file = new File(filePath); MimeTypeMap map = MimeTypeMap.getSingleton(); String ext = MimeTypeMap.getFileExtensionFromUrl(file.getName()); String type = map.getMimeTypeFromExtension(ext); if (type == null) type = “*/*”; Intent intent = new … Read more

Android opening a file with ACTION_GET_CONTENT results into different Uri’s

Use below code.This will work for sure. public static String getPath(Context context, Uri uri) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // DocumentProvider if (DocumentsContract.isDocumentUri(context, uri)) { // ExternalStorageProvider if (isExternalStorageDocument(uri)) { final String docId = DocumentsContract.getDocumentId(uri); final String[] split = docId.split(“:”); final String type = split[0]; if (“primary”.equalsIgnoreCase(type)) { return Environment.getExternalStorageDirectory() + “https://stackoverflow.com/” + split[1]; … Read more