I’m implementing in-app billing support in my application. I just realized that even though the application has been stopped, the standard billing broadcast receiver is still receiving billing messages from the market service. So, instead of declaring my receiver inside the manifest file:
<receiver android:name=".receiver.billing.BillingReceiver">
<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>
I decided to go with the Context.registerReceiver method in order to ensure that my application is actually ready to correctly handle billing messages:
_billingReceiver = new BillingReceiver();
final IntentFilter filter = new IntentFilter("com.android.vending.billing.IN_APP_NOTIFY");
filter.addAction("com.android.vending.billing.RESPONSE_CODE");
filter.addAction("com.android.vending.billing.PURCHASE_STATE_CHANGED");
_billingService.registerReceiver(_billingReceiver, filter);
The problem now is that BillingReceiver.onReceive is not called anymore. Is there an issue of some kind preventing billing messages to be sent to dynamically registered receivers. I looked through Google/Android’s doc and found nothing.
Why do you not want to receive billing messages when the application has been stopped? It means that you could miss important messages from the market about purchases and refunds.
You’ll notice that in the dungeons example they have a database that they log all purchase information to. Then their UI uses the database to keep the user informed about the status of their purchase. This is so that if a user went to some other app while their purchase was being processed they could come back and see that the purchase had completed successfully.