Back pressed events with system alert window

后端 未结 10 1545
南笙
南笙 2021-01-03 03:21

I need to dismiss system alert window on back pressed and home button event.I have tried with onKeyEvent but in vain. As we can\'t cap

10条回答
  •  渐次进展
    2021-01-03 04:07

    It's simple. Follow these steps:

    1. Create a view like Relative Layout, Linear Layout or Frame Layout Dynamically. 2. Override the dispatchKeyEvent while creating the view.
    2. Add your original view into this dynamically created view with addView() method.
    3. Add the dynamically created view to your Window Manager or Alert Dialog whichever you want.

提交回复
热议问题