Android 无法使用服务与MarketBillingService断开连接

Android 无法使用服务与MarketBillingService断开连接,android,in-app-billing,Android,In App Billing,根据谷歌地下城的例子,当我尝试实现应用内购买时,似乎出现了资源泄漏 当MarketbillingService在调用unbind函数中的unbindService(所有函数都在BillingService类中)后未调用onServiceDisconnected时,就会出现问题 所以我的问题是:如何将ServiceConnection发布到MarketBillingService /** * This class sends messages to Android Market on behal

根据谷歌地下城的例子,当我尝试实现应用内购买时,似乎出现了资源泄漏

当MarketbillingService在调用unbind函数中的unbindService(所有函数都在BillingService类中)后未调用onServiceDisconnected时,就会出现问题

所以我的问题是:如何将ServiceConnection发布到MarketBillingService

/**
 * This class sends messages to Android Market on behalf of the application by
 * connecting (binding) to the MarketBillingService. The application
 * creates an instance of this class and invokes billing requests through this service.
 *
 * The {@link BillingReceiver} class starts this service to process commands
 * that it receives from Android Market.
 *
 * You should modify and obfuscate this code before using it.
 */
public class BillingService extends Service implements ServiceConnection {

 [...]

/**
 * Unbinds from the MarketBillingService. Call this when the application
 * terminates to avoid leaking a ServiceConnection.
 */
public void unbind() {
    try {
        unbindService(this);
    } catch (IllegalArgumentException e) {
        // This might happen if the service was disconnected
    }
}


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