Display Applications that can handle a particular filetype
So, I have the file path of a file in an application & I want to give the user the ability to select from all applications on the phon开发者_开发问答e that can handle/open that file type and then open the file in that applicaton. How do I do this? - performs a similar function to a file manager.
First you have to pick the type of Intent you want. This code picks applications that can send the data through SMS/email/etc utilizing ACTION_SEND
.
Intent intent = new Intent(Intent.ACTION_SEND);
Next you need to use putExtra to get the file/message to the Intent.
Uri uri = Uri.fromFile(new File(myFile));
intent.putExtra(Intent.EXTRA_STREAM, uri);
Finally you create a chooser.
Intent chooser = Intent.createChooser(intent, "A Custom Message");
startActivity(chooser);
精彩评论