Presentation class in jelly Bean Plus does not intercept onTouchEvent

I am developing an Android application that displays unique content on a secondary display. Presentation class was recently introduced in Bean Plus Jelly (4.2.1). This is a special kind of dialog that aims to provide content on a secondary display. I am testing my application using a secondary display simulator which can be opened from settings - developer options. Now I would like to intercept touch events on the secondary display. Take a look at my view class

public class NewPresentation extends Presentation {

    public NewPresentation(Context outerContext, Display display) {
        super(outerContext, display);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.notes_preview);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return super.onTouchEvent(event);
    }
}

      

But this onTouchEvent doesn't fire when I touch somewhere on the secondary display.

I doubt that since Presentation extends Dialog which cannot intercept touch events (not sure) the presentation class

Is there a way to make the Presentation class intercept touch events? Please help me.

+3


source to share


1 answer


As the presentation class expands to a dialog and the dialog itself is available, you can receive touch events from your presentation class. I tried the sample app on a device with an extra display and touch input and it worked. Your secondary display may not support touch support.



0


source







All Articles