手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >Android键盘输入语言设置默认打开myanmar缅甸语的步骤
Android键盘输入语言设置默认打开myanmar缅甸语的步骤
摘要:locale是通过系统设置的地区和latin输入法语言通过merger出来的,所以在系统地区设置和输入法语言中同时支持才可以在“输入语言设置...

locale是通过系统设置的地区和latin输入法语言通过merger出来的,所以在系统地区设置和输入法语言中同时支持才可以在“输入语言设置“里设置

languageList是从存储latin输入法设置的latin_preferences.xml文件里读取出来的,上一次设置的输入语言

如果要设置某种语言在输入法默认打开可按一下步骤添加文件,我这里已经验证时OK的,你可以试一下。

提供简单的sample code,如默认将缅甸语、英文、法语输入法勾选:

1.书写文件LatinImeReceiver.java

复制代码 代码如下:

package com.android.inputmethod.latin;

import android.content.BroadcastReceiver;

import android.content.Context;

import android.content.Intent;

import android.content.SharedPreferences;

import android.content.SharedPreferences.Editor;

import android.preference.PreferenceManager;

import android.provider.Settings;

import android.util.Log;

import android.view.inputmethod.InputMethodInfo;

import android.view.inputmethod.InputMethodManager;

//import android.view.inputmethod.InputMethodSubtype;

import android.text.TextUtils;

public class LatinImeReceiver extends BroadcastReceiver {

private static final String TAG = LatinImeReceiver.class.getSimpleName();

@Override

public void onReceive(Context context, Intent intent) {

Log.d("LatinImeReceiver", "step1");

SharedPreferences sp = context.getSharedPreferences("com.android.inputmethod.latin_preferences",

Context.MODE_PRIVATE);

boolean hasSet = sp.getBoolean("has_set", false);

if (!hasSet) {

Log.d("LatinImeReceiver", "step2");

Editor editor = sp.edit();

Log.d("LatinImeReceiver", "step3");

editor.putString(LatinIME.PREF_SELECTED_LANGUAGES, "en_US,my,fr"); //默认将英语、缅甸语勾选,具体该怎么写可以参考inputlanguageselection.java中的WHITELIST_LANGUAGES

editor.putBoolean("has_set", true);

Log.d("LatinImeReceiver", "step4");

//editor.commit();

SharedPreferencesCompat.apply(editor);

Log.d("LatinImeReceiver", "step5");

}

}

将其放置到路径packages/inputmethods/LatinIME/java/src/com/android/inputmethod/latin文件夹下面

2.注册intent,在packages/inputmethods/LatinIME/java/androidManifest.xml中的最后面加入:

并增加 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />权限

复制代码 代码如下:

<receiver android:name="LatinImeReceiver" android:enabled="true">

<intent-filter>

<action android:name="android.intent.action.BOOT_COMPLETED" />

</intent-filter>

</receiver>

【Android键盘输入语言设置默认打开myanmar缅甸语的步骤】相关文章:

Android 通用型手电筒代码

Android中手机震动的设置(Vibrator)的步骤简要说明

Android 如何修改默认输入法

如何与Android实体设备的连接

Android应用中调用系统软件打开各种各样的文件

Android中3种图片压缩处理方法

Android监听键盘上的确定键

android项目打包jar

Android里实现退出主程序的提示代码

Android程序打开和对输入法的操作(打开/关闭)

精品推荐
分类导航