简体   繁体   中英

Android: Filtering invite apps using Intents

I am working on android Intent class to implement the 'Invite Friends' screen. I used the below code for it.

The above code returns me the apps like bluetooth, flipboard, facebook, whatsapp etc.

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.invite_friends));
sendIntent.setType("text/plain");

Intent chooser = Intent.createChooser(sendIntent,getString(R.string.invite_send_tittle));

if (sendIntent.resolveActivity(getPackageManager()) != null)
{
    startActivity(chooser);
}

What I need is only messaging(sms, whatsapp, twitter etc.) and email apps. How to get only messaging and email apps?

In short I am looking for invite options like WhatsApp.

Thanks, Aditya

I would not do that since who knows how the user can communicate with friends - Twitter, Instagram, etc. As well there are millions of messengers and there is no way in Intent say I need a messenger .

If you still want to do selector for specific apps then you need own app selector with next steps:

  1. Query all possible apps that are able to share text ( Is there any way to query an specific type of Intent Filter capable apps? )
  2. Create own bottom sheet, dialogue or new screen with list

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM