String mimetype = ".docx\tapplication/vnd.openxmlformats-officedocument.wordprocessingml.document";
File file = new File(FilePath, filename);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), mimetype);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
I use above code to read a .docx file.
How can I check whether application can support the file format or not?
If not, below message:
Toast.makeText(this, "Not be supported.", Toast.LENGTH_LONG).show();
Make a function like this and give it your intent. It will check if there is any app able to process this intent.