Android inapp billing - BillingService在onServiceConnected和onServiceDisconnected上有编译错误

Gen*_*nik 5 android android-billing

我正在使用Dungeons应用程序示例,我正在使用该示例中提供的BillingService类.

我正在使用Java 6和@override为我工作,但我在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;
}
Run Code Online (Sandbox Code Playgroud)

有人会帮我理解为什么会这样吗?

谢谢!

Ran*_*Ran 5

确保您的类实现了ServiceConnection接口.


Joh*_*ith 3

我认为你应该简单地从这两个方法中删除 @Override 装饰器。我正在使用 Google BillingService 类,这是我的方法:

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

您正在实现一个接口,而不是使用抽象方法扩展一个类。