Search code examples
androidandroid-intentintentfilter

Send photo but filter some apps


I use below code to send photo to other apps.

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("image/jpeg");
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(FilePath));
startActivity(Intent.createChooser(sharingIntent, "Share via"));

But I want to filter some apps. For example, I didn't want to share to Facebook. And I know its package name is com.facebook.katana. How can I filter while showing all apps which I can share photo to?


Solution

  • Pretty simular to this, you can create your Intent and use queryIntentActivities() instead. It will give you a List of applications, from which you'll have to manually filter out some apps you do not want in there.

    You will probably have to create your own dialog after this though.