how to show app list to open a file
<p>I'm trying to give the user an overview over the apps which can be used to open the selected file. The following code doesn't work properly:</p>

<pre><code>String ext = MimeTypeMap.getFileExtensionFromUrl(file2open);

        String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext);

        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.parse(file2open), mime);
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        startActivity(intent);
</code></pre>

<p>If a .txt-file is selected, a list with two apps is shown. But no one of them is the right one. If a .pdf-file is selected, on my phone, a pdf-reader will be launched but only the app. The file is not getting opened. How can I show a list with all apps installed on the device to make the user select one, for example, if a file name doesn't contain an extension?</p>