Search code examples
androidin-app-billingdispose

Android billingHelper.dispose() Usage


How important is it to dispose of the helper? Also is it always needed to be placed on activity.destroy ?


Solution

  • As per android documentation, If you don’t unbind, the open service connection could cause your device’s performance to degrade.

    It is generally a good practice to unbind all the listeners once the task is no more needed. This improves your device battery utilization of the application.

    As a Mobile performance engineer, i have come across several applications where not turning off the listener or service, impacting the app battery utilization to a significant level.

    @Override
    public void onDestroy() {
       super.onDestroy();
       if (mHelper != null) mHelper.dispose();
       mHelper = null;
    }