首页 > 解决方案 > 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

标签: androidandroid-intentintentfilter

解决方案


设置数据应该可以解决问题。 mailIntent.setData(Uri.parse("mailto:"));


推荐阅读