Не включается на ServiceDesconnected от MarketBillingService - PullRequest
2 голосов
/ 30 ноября 2011

Кажется, что я получаю утечку ресурсов, когда пытаюсь осуществить покупку в приложении в соответствии с примером Google Dungeons.

Проблема возникает, когда MarketbillingService не вызывает onServiceDisconnected () после вызова unbindService () в функции unbind () (все из которых находятся в классе BillingService).

Так что мойпроблема заключается в следующем: как освободить 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;
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...