开发者

leaked IntentReceiver android.widget.ZoomButtonsController?

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 appea开发者_如何学JAVArs 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


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.


Add this to your activity:

  @Override
    public void finish() {
        ViewGroup view = (ViewGroup) getWindow().getDecorView();
        view.removeAllViews();
        super.finish();
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜