android - queryIntentActivities method returns empty List for API level 23 (Marshmallow) and below
问题描述
I am trying to check for capabilities of all installed apps to handle "Intent.ACTION_SENDTO" for which I am using the following snippet of code.
Intent mailIntent = new Intent(Intent.ACTION_SENDTO);
infos = manager.queryIntentActivities(mailIntent, 0);
Log.i(TAG,"number of apps that can hadle ACTION_SENDTO "+infos.size());
if(infos.size()>0){
//do actions
}
This snippet seemed to give proper result for Android N and above but for API level 23 and below this snippet gives me emptyList. however the interesting part is even for devices of API level 23 and below the Intent.ACTION_SENDTO is handled by mail apps and the email application is launced when i run the below snippet
Intent i = new Intent(Intent.ACTION_SENDTO,Uri.parse(UIConstants.EMAIL_URI+mEmail));
startActivity(i);
Can anyone help me understand why infos.size()
retuns 0 in my first snippet for API level 23 and below
解决方案
设置数据应该可以解决问题。
mailIntent.setData(Uri.parse("mailto:"));
推荐阅读
- php - PHP在带有截止时间的选项选择中获取当前时间
- ios - iOS中图像的UIImageJPEGRepresentation vs UIImagePNGRepresentation
- angular - ngx-datatable 可拖动行
- jboss - websphere 中 jboss 等价物的 Standalone.xml 文件
- wpf - 如何使用 servicestack 创建在线离线应用程序
- python - TFDV Tensorflow 数据验证:如何将 protobuf 模式保存到文件/从文件中加载
- bash - sed 替换具有特殊字符的变量
- solr - SOLR支持团队的流程是什么?
- android - Recyclerview中的对话框onClick
- codenameone - 代号一 - addCommand 不添加菜单