tags:

views:

200

answers:

1

I want my application to display a ZoomButtonsController on a GLSurfaceView whenever the user touches the GLSurfaceView. My activity constructor looks like this:

_zoomButtonsController = new ZoomButtonsController(_surface);
_zoomButtonsController.setAutoDismissed(true);            
_zoomButtonsController.setOnZoomListener(_zoomListener);  // Set listener

Then I override onTouchEvent() to make the ZoomButtonsController visible when the user generates an ACTION_MOVE event:

/** Called when user generates touch event */
@Override
public boolean onTouchEvent(MotionEvent event) {
    switch (event.getAction()) {
    case MotionEvent.ACTION_MOVE:
        // Does this somehow register an IntentListener??? 
        if (_zoomButtonsController != null) {
            _zoomButtonsController.setVisible(true);
        }

The application appears to work until I exit, at which time I get:

D/Solaris (22616): onDestroy() E/WindowManager(22616): Activity com.tomoreilly.solarisalpha.SolarisAlpha has leaked window android.widget.ZoomButtonsController$Container@4495c640 that was originally added here

and the stack trace refers to the line in onTouchEvent where _zoomButtonsController.setVisible(true) was called.

Why is this? Why does setting the zoom button controller visible also register it as an intent listener? And how the heck do I unregister it? Am I actually using the proper approach - i.e. should I call ZoomButtonsController.setVisible(true) from within Activity.onTouchEvent()?

Thanks, Tom

A: 

Why are you mentioning IntentReceivers? The log says that you leaked a window. You must make sure to set the zoom controller's visibility to false on exit to destroy the associated window.

Romain Guy
Thanks Guy - yes, calling ZoomButtonsController.setVisible(false) within Activity.onDestroy() fixes the immediate problem. But I do not understand why. Could someone please refer me to a complete example of ZoomButtonsController usage? I have been unable to find one.
Tom
Because the zoom controller creates a window and you have to destroy that window.
Romain Guy
Yikes - I overlooked a statement in the API - it's right in front of my face: "If you are using this with a custom View, please call setVisible(false) from the onDetachedFromWindow()." Thanks guys.
Tom