我想从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>
有可能吗?
答案 0 :(得分:2)
您可以通过调用PackageManager的getReceiverInfo方法检索它,下面的代码在活动中调用
PackageManager packageManager = getPackageManager();
ActivityInfo receiverInfo = packageManager.getReceiverInfo(new ComponentName(this, ReceiverName.class), 0);