Android billing - should I implement the ServiceCo

2019-01-27 04:04发布

I am looking at the Android in-app billing tutorial here:

http://developer.android.com/guide/google/play/billing/billing_integrate.html

and they have an instruction to implement the iMarketBillingService. But I saw in another example that the ServiceConnection method was implemented.

Which one should it be?

I am having confusion because I am trying to do something like this:

            Bundle request = makeRequestBundle("CHECK_BILLING_SUPPORTED");
            Bundle response = mService.sendBillingRequest(request);

but not sure what mService variable should be. In the Dungeons tutorial from Andoroid, they have this: private BillingService mBillingService;

but when I try to do this:

Bundle response = mBillingService.sendBillingRequest(request);

I get a syntax error saying that the method sendBillingRequest is undefined for BillingService.

So essentially I am getting confused in my different services and interfaces that I need to be working with. Please help me understand what is the correct approach for me.

Thank you!

1条回答
叛逆
2楼-- · 2019-01-27 04:37

I know the pain. I have found android inapp billing sdk more complex than it should be. Frankly I just dont get it, why does it need to be so complex. To ease it out, I basically use a simple helloworld for inapp billing. Get it working, running for my login and then start worrying about my logic. This is like driving in the reverse gear, but to save time, effort I use this technique for complex sdk.

I get the helloworld working, and keep this as a separate project. This helps debugging later when I get into upgrade or some other issues. Integrating this into my project is just messing with fire :).

I have a helloworld zip out there for you to download and try. Hope it helps. Integrate In App Billing in just 3 lines of code

查看更多
登录 后发表回答