Android 无法使用广播接收器中的意图筛选器列出应用程序

Android 无法使用广播接收器中的意图筛选器列出应用程序,android,android-intent,Android,Android Intent,我想列出应用程序(具有相同的目的过滤器)。我可以通过向活动添加意图过滤器来实现这一点 <activity android:name=".Activities.MainActivity" android:launchMode="singleTask" android:screenOrientation="portrait" android:windowSoftInputMode=

我想列出应用程序(具有相同的目的过滤器)。我可以通过向活动添加意图过滤器来实现这一点

         <activity
            android:name=".Activities.MainActivity"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden|adjustNothing">

            <intent-filter>
                <action android:name="com.example.identifier" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="isApp" />
            </intent-filter>
        </activity>
但我想让它呼叫广播接收器。因此,我将意图移动到AndroidManifest.xml中的广播接收器,如:

<receiver
            android:name=".ExampleReceiver"
            android:enabled="true">
            <intent-filter>
                <action android:name="com.example.identifier" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="isApp" />
            </intent-filter>
        </receiver>


而返回具有此目的的应用程序数的代码段现在返回0,即使该应用程序仍在此设备上。这可以用广播接收机来做,还是我应该用另一种方法考虑。谢谢。

调用
queryIntentActivities()
只会返回
Activity
s。它不会返回
BroadcastReceiver
s。如果您想使用
BroadcastReceiver
s执行此操作,则需要调用
querybroadcastReceiver()

但Intent zoneIntent=new Intent(“com.example.identifier”,Uri.parse(Uri));Intent openInChooser=Intent.createChooser(区域内容,“使用“).setFlags完成操作”).setFlags(Intent.FLAG\u活动\u新任务);上下文。startActivity(openInChooser);与我在活动中使用intentfilter时不同,没有显示此应用。没错,因为“选择器”只查找
活动
s,而不查找
广播接收器
s。
Intent zoneIntent = new Intent("com.example.identifier",
                    Uri.parse(uri));
            Intent openInChooser = Intent.createChooser(zoneIntent, "Complete Action with").setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(openInChooser);
<receiver
            android:name=".ExampleReceiver"
            android:enabled="true">
            <intent-filter>
                <action android:name="com.example.identifier" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="isApp" />
            </intent-filter>
        </receiver>