Skip to content Skip to sidebar Skip to footer

How Filter Json Files With Intent.action_open_document?

When I try to open a .json file with startActivityForResult(Intent(Intent.ACTION_OPEN_DOCUMENT).apply { addCategory(Intent.CATEGORY_OPENABLE) type = 'application/json' }, 0

Solution 1:

Android does not support json as a MIME type. You can check out the source codes of MimeUtils.

MimeTypeMap.getSingleton().getMimeTypeFromExtension("json");

returns null;

You can use "application/octet-stream" instead of "application/json" . It will show "*.json files among other files though it will filters out images, videos, music & text files.

Post a Comment for "How Filter Json Files With Intent.action_open_document?"