我想显示用户在手机中安装的所有消息收发应用程序。我期望的列表是,如WhatsApp,Facebook Messenger,Viber,Slack,Skype,微信等(如果已安装)。因此,到目前为止,我已经尝试通过以下代码在Phone中获取所有应用程序:
val pm: PackageManager = context!!.packageManager
val i = Intent(Intent.ACTION_MAIN)
i.addCategory(Intent.CATEGORY_LAUNCHER)
val lst = pm.queryIntentActivities(i, 0)
for (resolveInfo in lst) {
Log.d(
"Test",
"New Launcher Found: " + resolveInfo.activityInfo.packageName
)
这只给了我Slack应用程序,却没有其他消息传递应用程序。我有一种感觉,它与Google文档中提到的MIME类型有关。
text/*, senders will often send text/plain, text/rtf, text/html, text/json
image/*, senders will often send image/jpg, image/png, image/gif
video/*, senders will often send video/mp4, video/3gp
但我不知道如何使用此信息。任何帮助,将不胜感激。 TIA!
最佳答案
在创建您的意图时添加ACTION_SENDTO
作为操作参数,您应该会看到能够处理消息/短信等的应用列表。val intent = Intent(Intent.ACTION_SENDTO)
// get list of activities that can handle this type of intent
val lst = pm.queryIntentActivities(intent, 0)
关于android - 显示Android手机中安装的所有消息传递应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62254636/