Android鍵盤輸入語言設(shè)置默認(rèn)打開myanmar緬甸語的步驟
更新時(shí)間:2013年06月17日 15:56:56 作者:
如何實(shí)現(xiàn)Android鍵盤輸入語言默認(rèn)打開為myanmar緬甸語,如果要設(shè)置某種語言在輸入法默認(rèn)打開可按一下步驟添加文件,我這里已經(jīng)驗(yàn)證時(shí)OK的
locale是通過系統(tǒng)設(shè)置的地區(qū)和latin輸入法語言通過merger出來的,所以在系統(tǒng)地區(qū)設(shè)置和輸入法語言中同時(shí)支持才可以在“輸入語言設(shè)置“里設(shè)置
languageList是從存儲latin輸入法設(shè)置的latin_preferences.xml文件里讀取出來的,上一次設(shè)置的輸入語言
如果要設(shè)置某種語言在輸入法默認(rèn)打開可按一下步驟添加文件,我這里已經(jīng)驗(yàn)證時(shí)OK的,你可以試一下。
提供簡單的sample code,如默認(rèn)將緬甸語、英文、法語輸入法勾選:
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)將英語、緬甸語勾選,具體該怎么寫可以參考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" />權(quán)限
<receiver android:name="LatinImeReceiver" android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
languageList是從存儲latin輸入法設(shè)置的latin_preferences.xml文件里讀取出來的,上一次設(shè)置的輸入語言
如果要設(shè)置某種語言在輸入法默認(rèn)打開可按一下步驟添加文件,我這里已經(jīng)驗(yàn)證時(shí)OK的,你可以試一下。
提供簡單的sample code,如默認(rèn)將緬甸語、英文、法語輸入法勾選:
1.書寫文件LatinImeReceiver.java
復(fù)制代碼 代碼如下:
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)將英語、緬甸語勾選,具體該怎么寫可以參考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" />權(quán)限
復(fù)制代碼 代碼如下:
<receiver android:name="LatinImeReceiver" android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
相關(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ù)庫文件拷貝到安裝目錄的方法
這篇文章主要介紹了Android編程實(shí)現(xiàn)將壓縮數(shù)據(jù)庫文件拷貝到安裝目錄的方法,涉及Android處理壓縮文件的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-10-10Android在WebView中調(diào)用系統(tǒng)下載的方法
這篇文章主要為大家詳細(xì)介紹了Android在WebView中調(diào)用系統(tǒng)下載的簡單使用,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-05-05Android RxJava異步數(shù)據(jù)處理庫使用詳解
RxJava是一種異步數(shù)據(jù)處理庫,也是一種擴(kuò)展的觀察者模式。對于Android開發(fā)者來說,使用RxJava時(shí)也會搭配RxAndroid,它是RxJava針對Android平臺的一個(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針對相關(guān)源碼的修改與功能添加操作技巧,需要的朋友可以參考下2017-09-09android IntentService實(shí)現(xiàn)原理及內(nèi)部代碼分享
android IntentService實(shí)現(xiàn)原理及內(nèi)部代碼分享,需要的朋友可以參考一下2013-06-06