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

I am using the sample Dungeons application, and I am using the BillingService class provided in this example.

I use Java 6 and @override works for me, but I get a compilation error of 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;
}

Help me understand why this is happening?

Thank!

+5
source share
6 answers

I think you just need to remove the @Override decorator from both methods. I am using the Google BillingService class and this is my method:

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

You implement the interface without extending the class with abstract methods.

+3
source

Make sure your class implements the interface ServiceConnection.

+5

. , , . , , , . , google , , . , helloworld , . , .

Android inapp Eclipse

+4

.

( Control-Click) ""

" Java"

" "

Eclipse , .

+2

... Android-, ... , , . , , .

+1

→ Android- →

This fixed it for me (I believe it was a Java compiler option discarding it).

+1
source

All Articles