Android IME intercept key takes precedence over view

Source: Internet
Author: User

In order to verify that an example was written

The first is the input method

public class Remotekeyboard extends Inputmethodservice  {  @Override public boolean onKeyDown (int keycode, KeyEvent event) {        if (Processkey (event, 0! = Event.getrepeatcount ()))            return true;        Return Super.onkeydown (KeyCode, event);    }    @Override public boolean onKeyUp (int keycode, keyevent event) {        if (Processkey (event, true))            return true;        Return Super.onkeyup (KeyCode, event);    }    Private Boolean Processkey (KeyEvent event, Boolean doIt) {         log.e ("=======", "============ Processkey"); return Fals e;}}

Next is the app view

    Final TextView Et1 = (TextView) Findviewbyid (R.ID.EDITTEXT1); Et1.setonkeylistener (new Onkeylistener () {        @Override Public        Boolean OnKey (View v, int keycode, keyevent event)        {        log.e ("====================", "====onkeylistener");        }

Run Program Print

============================: ============ Processkey

====================: ====onkeylistener

============================: ============ Processkey

====================: ====onkeylistener

The first time should be KeyDown, the second time should be KeyUp, indicating that the Android IME interception key takes precedence over the view


And experimented with rewriting system/usr/keychars/generic.kcm.

Change B to

Key B {
Base: ' B ' fallback dpad_center
}

In a non-editable box, log the following

12-23 05:18:09.093 118 118 E ============================: ============ processkey

12-23 05:18:09.094 118 118 E ============================: ============ processkey
12-23 05:18:09.163 118 118 E ============================: ============ processkey
12-23 05:18:09.163 118 118 E ============================: ============ processkey

Note B was not accepted and then called the Dpad_center


In an editable box, B is accepted, log is as follows

============================: ============ Processkey

============================: ============ Processkey

Description does not call fallback


If the modification is as follows

Key B {
Base:fallback Dpad_center
}

In an editable box also to play 4 lines of log, indicating that fallback was called

Android IME intercept key takes precedence over view

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.