简体   繁体   English

Android:使用Intents过滤邀请应用

[英]Android: Filtering invite apps using Intents

I am working on android Intent class to implement the 'Invite Friends' screen. 我正在使用Android Intent类来实现“邀请朋友”屏幕。 I used the below code for it. 我使用下面的代码。

The above code returns me the apps like bluetooth, flipboard, facebook, whatsapp etc. 上面的代码返回我的应用程序,如蓝牙,flipboard,脸书,whatsapp等。

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. 我需要的只是消息(短信,whatsapp,推特等)和电子邮件应用程序。 How to get only messaging and email apps? 如何只获取消息和电子邮件应用程序?

In short I am looking for invite options like WhatsApp. 总之,我正在寻找像WhatsApp这样的邀请选项。

Thanks, Aditya 谢谢,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 . 我不会这样做,因为谁知道用户如何与朋友交流 - 推特,Instagram等等。同样有数百万的信使,并且Intent没有办法说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? ) 查询所有可能共享文本的应用程序( 有没有办法查询特定类型的支持Intent Filter的应用程序?
  2. Create own bottom sheet, dialogue or new screen with list 使用列表创建自己的底部工作表,对话框或新屏幕

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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