android - Removing Cast.Listener in teardown -


working on chromecast sender app, having hard time find api unregistering com.google.android.gms.cast.cast.listener in teardown implementation.

this how api client being constructed:

castlistener castlistener = new castlistener(); cast.castoptions.builder apioptionsbuilder = cast.castoptions     .builder(device, castlistener); googleapiclient apiclient = new googleapiclient.builder(context)     .addapi(cast.api, apioptionsbuilder.build())     .addconnectioncallbacks(connectioncallbacks)     .addonconnectionfailedlistener(connectionfailedlistener)     .build(); 

and here bits of teardown() implementation:

apiclient.unregisterconnectioncallbacks(connectioncallbacks); apiclient.unregisterconnectionfailedlistener(connectionfailedlistener); apiclient.disconnect(); apiclient = null; 

there seems unregister* methods connections callbacks , failed listeners, not removing cast listener. after teardown, castlistener methods being executed (onvolumechanged) assume disposal of googleapiclient not complete. there else can done in teardown? hidden removeapi() method on googleapiclient?

currently there apiclient!=null check in castlistener.onvolumechanged() avoid condition , rather have solution cast listener disposed in teardown().

any ideas?


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -