zoukankan      html  css  js  c++  java
  • keydown 事件响应处理

    java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
    at android.app.Activity.onBackPressed(Activity.java:2066)
    at android.app.Activity.onKeyDown(Activity.java:1962)
    at android.view.KeyEvent.dispatch(KeyEvent.java:2482)
    at android.app.Activity.dispatchKeyEvent(Activity.java:2274)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1668)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)
    at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1112)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1720)
    at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1258)
    at android.app.Activity.dispatchKeyEvent(Activity.java:2269)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1668)
    at android.view.ViewRoot.deliverKeyEventPostIme(ViewRoot.java:2851)
    at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2824)
    at android.view.ViewRoot.handleMessage(ViewRoot.java:2011)
    at android.os.Handler.dispatchMessage(Handler.java:99)

    其说明keydown 事件不能在onSaveInstanceState之后执行。

    1. 为什么按键消息会在onSaveInstanceState之后执行

    2. 为什么按钮响应消息不能在onSaveInstanceState之后执行,那其应该在哪个方法之后才能执行

    1. A –>B 

    2. b  pres back key

    3.   b 响应了 onkeydown 而之前 A是响应onKeyUp

    --> 导致 b 在响应onkeydown之后,就没有响应onKeyUp了,系统就从下就keyup发送到其他activity, 而A就响应了keyup消息,但A应该是在onresum之后才响应onKeyup消息才是合理了。

    改法:

    A响应keydown消息

    说明:

    1. http://stackoverflow.com/questions/7469082/getting-exception-illegalstateexception-can-not-perform-this-action-after-onsa

  • 相关阅读:
    python变量及简单数据类型
    python函数小案例
    python字符串和列表小案例
    python循环输出
    Jmeter测试工具
    操作系统-进程管理~
    操作系统~
    组成原理第一章笔记~
    分时间段(年份或月份)统计,没有数字补0 Java(替代 MYSQL) 做法
    组成原理复习概略
  • 原文地址:https://www.cnblogs.com/pengxinglove/p/4369209.html
Copyright © 2011-2022 走看看