Android鍵盤輸入語(yǔ)言設(shè)置默認(rèn)打開myanmar緬甸語(yǔ)的步驟
languageList是從存儲(chǔ)latin輸入法設(shè)置的latin_preferences.xml文件里讀取出來(lái)的,上一次設(shè)置的輸入語(yǔ)言
如果要設(shè)置某種語(yǔ)言在輸入法默認(rèn)打開可按一下步驟添加文件,我這里已經(jīng)驗(yàn)證時(shí)OK的,你可以試一下。
提供簡(jiǎn)單的sample code,如默認(rèn)將緬甸語(yǔ)、英文、法語(yǔ)輸入法勾選:
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"); //默認(rèn)將英語(yǔ)、緬甸語(yǔ)勾選,具體該怎么寫可以參考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.注冊(cè)intent,在packages/inputmethods/LatinIME/java/androidManifest.xml中的最后面加入:
并增加 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />權(quán)限
<receiver android:name="LatinImeReceiver" android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
- 解析android中隱藏與顯示軟鍵盤及不自動(dòng)彈出鍵盤的實(shí)現(xiàn)方法
- Android 顯示和隱藏軟鍵盤的方法(手動(dòng))
- Android 設(shè)置Edittext獲取焦點(diǎn)并彈出軟鍵盤
- Android制作漂亮自適布局鍵盤的方法
- Android鍵盤顯示與隱藏代碼
- Android實(shí)現(xiàn)彈出鍵盤的方法
- Android中監(jiān)聽軟鍵盤顯示狀態(tài)實(shí)現(xiàn)代碼
- Android 軟鍵盤彈出時(shí)把原來(lái)布局頂上去的解決方法
- Android軟鍵盤遮擋的四種完美解決方案
- Android自定義控件之電話撥打小鍵盤
相關(guān)文章
Android編程獲取系統(tǒng)隱藏服務(wù)實(shí)現(xiàn)鎖屏的方法
這篇文章主要介紹了Android編程獲取系統(tǒng)隱藏服務(wù)實(shí)現(xiàn)鎖屏的方法,涉及Android關(guān)于廣播,服務(wù),權(quán)限及鎖屏等操作的相關(guān)技巧,需要的朋友可以參考下2015-12-12Android三種方式實(shí)現(xiàn)ProgressBar自定義圓形進(jìn)度條
這篇文章主要介紹了Android三種方式實(shí)現(xiàn)ProgressBar自定義圓形進(jìn)度條的相關(guān)資料,需要的朋友可以參考下2016-03-03Android編程實(shí)現(xiàn)將壓縮數(shù)據(jù)庫(kù)文件拷貝到安裝目錄的方法
這篇文章主要介紹了Android編程實(shí)現(xiàn)將壓縮數(shù)據(jù)庫(kù)文件拷貝到安裝目錄的方法,涉及Android處理壓縮文件的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-10-10Android開發(fā)入門之對(duì)話框簡(jiǎn)單用法
這篇文章主要介紹了Android對(duì)話框簡(jiǎn)單用法,涉及Android對(duì)話框的功能、定義、創(chuàng)建及使用等相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2016-07-07Android在WebView中調(diào)用系統(tǒng)下載的方法
這篇文章主要為大家詳細(xì)介紹了Android在WebView中調(diào)用系統(tǒng)下載的簡(jiǎn)單使用,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-05-05Android RxJava異步數(shù)據(jù)處理庫(kù)使用詳解
RxJava是一種異步數(shù)據(jù)處理庫(kù),也是一種擴(kuò)展的觀察者模式。對(duì)于Android開發(fā)者來(lái)說,使用RxJava時(shí)也會(huì)搭配RxAndroid,它是RxJava針對(duì)Android平臺(tái)的一個(gè)擴(kuò)展,用于Android 開發(fā),它提供了響應(yīng)式擴(kuò)展組件,使用RxAndroid的調(diào)度器可以解決Android多線程問題2022-11-11Android 6.0開發(fā)實(shí)現(xiàn)關(guān)機(jī)菜單添加重啟按鈕的方法
這篇文章主要介紹了Android 6.0開發(fā)實(shí)現(xiàn)關(guān)機(jī)菜單添加重啟按鈕的方法,涉及Android6.0針對(duì)相關(guān)源碼的修改與功能添加操作技巧,需要的朋友可以參考下2017-09-09android IntentService實(shí)現(xiàn)原理及內(nèi)部代碼分享
android IntentService實(shí)現(xiàn)原理及內(nèi)部代碼分享,需要的朋友可以參考一下2013-06-06