我可以从AndroidManifest.xml获取接收者信息吗?

时间:2013-12-11 06:58:45

标签: android android-manifest

我想从java代码知道我的接收器类是否已注册到app的AndroidManifest.xml (我是图书馆开发人员,而不是app)

<receiver android:name="some class..." >
    <intent-filter> 
        <action android:name="com.android.vending.billing.IN_APP_NOTIFY" /> 
        <action android:name="com.android.vending.billing.RESPONSE_CODE" /> 
        <action android:name="com.android.vending.billing.PURCHASE_STATE_CHANGED" /> 
    </intent-filter> 
</receiver> 

有可能吗?

1 个答案:

答案 0 :(得分:2)

您可以通过调用PackageManager的getReceiverInfo方法检索它,下面的代码在活动中调用

PackageManager packageManager = getPackageManager();
ActivityInfo receiverInfo = packageManager.getReceiverInfo(new ComponentName(this, ReceiverName.class), 0);