質問

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,

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top