Search code examples
androidandroid-billing

Android inapp billing - BillingService has compile errors with onServiceConnected and onServiceDisconnected


I am using the Dungeons application example and I am using the BillingService class provided in that example.

I am using Java 6 and @override works for me, but I get a compile error on these two methods inside BillingService.java:

/**
 * This is called when we are connected to the MarketBillingService.
 * This runs in the main UI thread.
 */
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
    if (Consts.DEBUG) {
        Log.d(TAG, "Billing service connected");
    }
    mService = IMarketBillingService.Stub.asInterface(service);
    runPendingRequests();
}

/**
 * This is called when we are disconnected from the MarketBillingService.
 */
@Override
public void onServiceDisconnected(ComponentName name) {
    Log.w(TAG, "Billing service disconnected");
    mService = null;
}

Would someone help me understand why this is happening?

Thanks!


Solution

  • I think you should simply remove the @Override decorator from both methods. I'm using the Google BillingService class and this is my method:

    public void onServiceConnected(ComponentName name, IBinder service)
    {        
        mService = IMarketBillingService.Stub.asInterface(service);
        runPendingRequests();
    }
    

    You are implementing an interface, not extending a class with abstract methods.