Android In-App billing: Null Pointer Exception

喜欢而已 提交于 2019-12-05 22:35:38

onServiceConnected() is not being called before you try to use mService. That is because your activity's onServiceConnected() cannot be called until its onCreate() returns, which it has not yet done.

Basically you need to make your call to checkBilling() later, after the service has connected. You might do it in response to the service connection, or you might do it later when the user actually tries to do something.

FInally i found the solution on that problem. And it was my fault.

The error was in the manifest, in fact i declared in the service as

    <service android:name=".BillingService" />

But the BillingService class was in a subpackage (resistorcalc.main.billing). Then i replaced the line with:

    <service android:name=".billing.BillingService" />

And the service started to work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!