问题
My app has a single in-app purchase, and is modeled after the Dungeons sample that Google provides (viewable at http://code.google.com/p/marketbilling/source/browse/). The only difference is that the code to restore transactions on the first run has been separated out and placed in my app's main activity. (My modified "Dungeons" activity is where the user goes to purchase the plugin)
The restoreTransactions()
code in my main activity's onCreate()
works great on both a 2.3 and 1.6 test device:
if (!initialized)
{
BillingService mBillingService = new BillingService();
mBillingService.setContext(this);
if (mBillingService.checkBillingSupported())
{
mBillingService.restoreTransactions();
}
mBillingService.unbind();
}
However on a wifi-Xoom running 4.0.4, it seems to plow right through it without actually doing anything, until I open up my "Dungeons" activity, at which point everything which was supposed to happen in the main activity, happens (almost like it queues everything up but waits for something in "Dungeons" before actually acting on it).
Digging deeper I can see that onServiceConnected()
in BillingService.java is never called on the Xoom until I open my "Dungeons" activity, whereas it's called just fine on 2.3 & 1.6 without opening the same activity.
Has something changed in 4.x that is preventing this from working the way it does on earlier versions?
来源:https://stackoverflow.com/questions/10255735/in-app-billingservice-onserviceconnected-not-called-on-4-0-ics