Question

I want to report Video position when user presses back button. Video is played inside a Custom View implementation which is a part of SDK. So i dont have access to Activity's backButtonPressed method.

I tried dispatchKeyEvent but it requires view to be focused. It shouldn't be necessary.

Custom View implements FrameLayout and adds an instance of VideoView if it is expected to play video.

Is there any way to catch backbutton presses inside such a Custom View?

Thanks All,

Was it helpful?

Solution

You could use the Window events like onWindowVisibilityChanged, onDetachedFromWindow, etc., to take care of the pausing and reporting video position. Take a look at the second example in the setSystemUiVisibility documentation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top