I am trying to open File using Intent , but Android does not open the correct application for the file type.
Using the following code, each file - pdf, images, everything - is opened using a music application:
Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.fromFile(file)); startActivity(i);
When I manually specify mimeType, the correct application opens - in this case, the image viewer.
i.setDataAndType(Uri.fromFile(file), "image
Is there a way to get Android to open the right application instead of manually setting the type judging from the file extension?
source share