This article will take a question and answer form, collect some of the usual changes to the Android platform source encountered problems. Based on the Spreadtrum platform, other platforms are basically similar to modifications.
Case 1:What role does Android:imeoptions have?
Once there is a problem: fixed dial horizontal screen to save the input PIN2 code after the completion of the function failure. Check that the android:imeoptions= "Actiondone" property of the edit box is not set. Modify the Phone/res/layout/get_pin2_screen.xml file on android2.3.5, add @+id/pin for EditText android:id= "android:imeoptions=" Actiondone "Property After the problem is resolved.
By default, the button in the lower right corner of the soft keyboard is "next", click the next input box to keep the soft keyboard;
When setting android:imeoptions="Actiondone" , the soft keyboard becomes "done" and the cursor remains on the original input box when clicked. And the soft keyboard is off;
when setting android:imeoptions = "Actionsend" under the soft keyboard becomes "send", click the cursor after the next move.
Case2: How overseas projects automatically switch languages based on local SIM
Modified file: Mcctable.java (frameworks\opt\telephony\src\java\com\android\internal\telephony)
Locate the corresponding configuration information in the stable:
Written as follows Stable.add (new Mccentry (460, "cn", 2, "zh"));
Locale.region for CN, Locale.language for ZH location in China, automatically recognized as Chinese
CASE3:android4.4 How to remove the system language following the SIM card region transformation function?
If you want to remove the system language following the SIM Card region transformation function, modify the following method
In the Frameworks/opt/telephony/src/java/com/android/internal/telephony/mcctable.java file
Updatemccmncconfiguration () function Comment locale = GETLOCALEFROMMCC (context, MCC);
or comment out if (locale! = NULL) {The following two sentences
Config.setlocale (locale);
Updateconfig = true;
Case4: How to add the Indian currency symbol rupee in the input method.
1. If you are a third-party input method, you need to contact a third party.
2. If it is an Android native Latin IME, you can find the Kbd_symbols.xml in the resource file. See below:
<key
Android:keylabel= "$"
android:popupkeyboard= "@xml/kbd_popup_template"
android:popupcharacters= "¢£€¥????"/>
Keylabel is the content of this key display, if it is a short press, the word on the screen.
If you press and hold, the popup pops up and the user chooses, the selected content is displayed in Popupcharacters,
The native Latin IME is available in the euro, franc and other currency symbols, which can be added to the rupee symbol.
3. If you need to add another symbol, it can be added in the same way as the rupee.
CASE5: How to configure Input method default sound and vibrator
Take Google Pinyin for example:
INITCONFS configuration function exists in Settings.java code
private void Initconfs () {
Mkeysound = Msharedpref.getboolean (Andpy_confs_keysound_key, true);
Mvibrate = Msharedpref.getboolean (Andpy_confs_vibrate_key, false);
Mprediction = Msharedpref.getboolean (Andpy_confs_prediction_key, true);
}
See Sound configuration (Andpy_confs_keysound_key, True), set to true to indicate that the default is turned on, false to turn off;
Vibrator is also so configured;
Case6: Input Method Open button vibration, felt too weak, how to solve
This problem if monomer is a single phone problem, the general hardware vibrator a bit of a problem, if not a single problem, through the software configuration can also achieve the need to strengthen the quake, the platform is specifically configured as follows:
Packages\inputmethods\pinyinime\src\com\android\inputmethod\pinyin\softkeyboardview.java:
Search for the Mvibratepattern keyword, configure it
such as protected long[] Mvibratepattern = new long[] {1, 20};
Change to protected long[] Mvibratepattern = new long[] {1, 50};
Case7: How to configure IME display and hide
In the application design, there are generally the following requirements for IME display/Hide:
1: When the input focus is received, the input method is required after the boot
2: When the activity jumps, it is required to hide the previous input focus binding input and other design requirements.
Here are three ways to configure:
One: Configured in Androidmainfest.xml,
Normally configured to eject the IME when the input focus appears
Android:windowsoftinputmode= "..." Configuration parameters are as follows:
Statehidden: The soft keyboard is always hidden when the user chooses activity
Statealwayshidden: The soft keyboard is always hidden when the activity main window gets the input focus
Statevisible: Soft keyboard is usually visible
Statealwaysvisible: The soft keyboard always displays the status when the user chooses activity
Adjustunspecified: Default setting, which is usually determined by the system to hide or show itself
There are two additional configurations to dynamically adjust the position of the input box
Adjustresize: The activity always adjusts the size of the screen to allow space for the soft keyboard
Adjustpan: The contents of the current window will automatically move so that the current focus is never covered by the keyboard and the user can always see the part of the input---this we use more,
Generally when the input focus more activity, configure this, the system will automatically adjust the activity interface, to ensure that the edittext will not be blocked by the IME. Typically compresses the layout between the title and the input box
Two: Configure in code
GetWindow (). Setsoftinputmode (WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
The windowmanager.layoutparams here have
Soft_input_adjust_pan
Soft_input_adjust_resize
Soft_input_state_always_visible
Soft_input_state_always_hidden
Soft_input_state_hidden
Soft_input_state_visible
Soft_input_state_unspecified
Soft_input_state_unchanged
Here the configuration and the above androidmanifest meaning is the same
If we are configured in the above two files, the last one is the configuration in the code
three: Dynamic display/Hide Input method when activity jumps
Hide
public void Hideinputmethod () {
Inputmethodmanager IMM = Getinputmethodmanager ();
if (IMM! = null) {
Imm.hidesoftinputfromwindow (Getwindowtoken (), 0);//The token here is the token of the current focus view
}
Show
public void Showinputmethod () {
Inputmethodmanager IMM = Getinputmethodmanager ();
if (IMM! = null) {
Imm.showsoftinput (this, 0);
}
}
Both of the above are commonly used dynamic display/Hide Input method
Case8: How to prevent a control from being repeatedly clicked too quickly
In Android development, to prevent the control from clicking too fast, you need to make sure that you have a valid click, that is, only one click event is recorded within the effective time
Private Boolean processflag = true; By default you can click
B_next the clicked Control
B_next.setonclicklistener (New Onclicklistener () {
public void OnClick (View v) {
if (Processflag) {
Setprocessflag ();//
Tonext ();//To perform the specific operation
New Timethread (). Start ();
}
}
});
/**
* Set a valid identifier for the button to be repeatedly clicked in a short period of time (true indicates that the click is valid, False indicates that the click is invalid)
*/
Private synchronized void Setprocessflag () {
Processflag = false;
}
/**
* Timed thread (prevents repeated click button during a certain period of time)
*/
Private class Timethread extends Thread {
public void Run () {
try {
Sleep (1000);
Processflag = true;
} catch (Exception e) {
E.printstacktrace ();
}
}
}
One of the Android source problem solutions (Input method)