Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我希望我的全屏 mobclix 广告在 2 秒内不可销毁。现在用户可以在广告出现之前按下安卓手机上的后退按钮。我怎样才能做到这一点?
您需要做的就是拦截按下后退按钮,您可以通过重载来做到这一点:
onBackPressed()
在较旧的设备上,这将无法正常工作,您需要执行以下操作:
public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { //Do something here return true; } return super.onKeyDown(keyCode, event); }