How Android modifies the default input method

Source: Internet
Author: User
Tags stmt tostring stringbuffer

First, applicable to ICS (Android V4.0) before the version:

1. Install the default input method (. apk) required to System/app

2. Modify File Frameworks/base/packages/settingsprovider/res/values/defaults.xml

   Default Input Method ID

A red flag indicates an input method ID, such as Pinyinime: com.android.inputmethod.pinyin/. Pinyinime

Second, applicable to ICS, JB, JB2 and after the version:

1. The default Input method (. apk) that needs to be used in advance will be built into the system (please refer to how to preset the APK into the system)

2. Modify File Mediatek/config/${project}/projectconfig.mk

Set the value of the macro Default_input_method to the desired input method;

such as Pinyinime, then set to: Default_input_method = Com.android.inputmethod.pinyin.PinyinIME

This value is the source of the input method, which contains the name of the Inputmethodservice subclass. The class name of the subclass that implements the Inputmethodservice. Here is one less "/" than the full class name printed in log, please note

Supplementary Note:

The above modification method only applies to the default input method of com.android.inputmethod.pinyin/. Pinyinime This format input method (that is, after the backslash is the case of the class name),

For Com.google.andr

Oid.inputmethod.latin/com.android.inputmethod.latin.latinime (that is, the case of the full class name after the backslash),

This situation is not supported by modifying MEDIATEK/CONFIG/${PROJECT}/PROJECTCONFIG.MK

Inside the Default_input_method method to set the default input method.

With Com.google.andr

Oid.inputmethod.latin/com.android.inputmethod.latin.latinime as an example

Use the following method to modify, in the Databasehelper.java of Settingsprovider

Yes

LOG.I (TAG, "defaultime:" + defaultime);

if (defaultime!= null) {

StringBuffer strbuffer = new StringBuffer (defaultime);

int lastdotpos = Defaultime.lastindexof (".");

String Strinsert = "/";

Strbuffer.insert (Lastdotpos, Strinsert);

Loadsetting (stmt, Settings.Secure.DEFAULT_INPUT_METHOD,

Strbuffer.tostring ());

} else {

LOG.I (TAG, "default IME from Imefeatureoption is null!!");

}

Remove the default initialization part of the code, and then delete the following code.

LOG.I (TAG, "defaultime:" + defaultime);

if (defaultime!= null) {

StringBuffer strbuffer = new StringBuffer (defaultime);

int lastdotpos = Defaultime.lastindexof (".");

String Strinsert = "/";

Strbuffer.insert (Lastdotpos, Strinsert);

Loadsetting (stmt, Settings.Secure.DEFAULT_INPUT_METHOD,

Strbuffer.tostring ());

} else {

LOG.I (TAG, "default IME from Imefeatureoption is null!!");

}

Then add the following after the deletion

Loadsetting (stmt, Settings.Secure.ENABLED_INPUT_METHODS,

"Com.google.andr

Oid.inputmethod.latin/com.android.inputmethod.latin.latinime "); Here to fix this default enable Input method

Loadsetting (stmt, Settings.Secure.DEFAULT_INPUT_METHOD,

"Com.google.andr

Oid.inputmethod.latin/com.android.inputmethod.latin.latinime ")//here Modify the default selected Input method

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.