Android键盘输入语言设置默认打开myanmar缅甸语的步骤

时间:2021-07-01 17:15:44 

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>
标签:键盘,输入语言,myanmar,缅甸语
0
投稿

猜你喜欢

  • Java NIO实例UDP发送接收数据代码分享

    2022-12-03 01:30:37
  • 详解C# WinForm如何实现自动更新程序

    2022-03-04 02:19:29
  • Java 信号量Semaphore的实现

    2023-06-19 11:00:34
  • android: targetSdkVersion升级中Only fullscreen activities can request orientation问题的解决方法

    2023-07-26 13:56:08
  • C#中可枚举类型详解

    2023-03-24 20:39:15
  • 详解Matisse与Glide--java.lang.NoSuchMethodError:com.bumptech.glide.RequestManager.load

    2021-06-21 02:09:19
  • 一篇文章带你轻松了解C# Lock关键字

    2023-08-15 20:48:32
  • SparkSQL开窗函数分析使用示例

    2022-04-16 02:26:32
  • Android实现手势滑动识别功能

    2022-06-23 00:16:59
  • c#可以创建任意控件的拖动方法

    2021-11-30 01:51:08
  • Java实战之制作在线音乐网站

    2021-11-11 01:36:02
  • Java实现LeetCode(1.两数之和)

    2021-06-03 02:11:19
  • Android开发input问题解决分析

    2021-11-10 08:58:46
  • C#调用Java方法实例详解

    2021-10-16 22:50:20
  • C#获取每个年,月,周的起始日期和结束日期的方法

    2023-11-11 20:53:45
  • C# JSON格式化转换辅助类 ConvertJson

    2023-09-27 19:40:20
  • android开发教程之判断是手机还是平板的方法

    2022-10-22 12:30:41
  • Spring Boot用户注册验证的实现全过程记录

    2023-01-03 01:58:34
  • springboot框架阿里开源低代码工具LowCodeEngine

    2022-09-01 09:40:41
  • java中main函数你知道多少

    2023-05-26 12:32:15
  • asp之家 软件编程 m.aspxhome.com