如何以编程方式在Android设备上获取当前的键盘语言 [英] How to programmatically get current keyboard language on an Android device

查看:110
本文介绍了如何以编程方式在Android设备上获取当前的键盘语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个使用字典的应用程序.每当用户更改输入语言时,我都希望在词典之间切换.例如,如果键入语言是英语,则使用英语词典;如果是德语,则使用德语词典.有什么方法可以设置侦听器以获取更改?我找到的所有答案都是关于语言环境的,而不是关于输入语言的.我不想处理语言环境,语言环境在应用程序中没有作用,输入语言却可以. (我正在用minSDK = 7开发)

I am writing an application which is using dictionaries. I want to switch between dictionaries any time user change input language. For example if the typing language is english work with english dictionary, if it is german, work with german dictionary. Is there any way to set a listener to get that change? All the answer i found were about locale and not about input language. I don't want to handle locale, locale has no effect in application, the input language does. (I am developing in minSDK=7)

推荐答案

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);

InputMethodSubtype ims = imm.getCurrentInputMethodSubtype();

String locale = ims.getLocale();

您可以尝试使用此代码来获取当前键盘语言"区域代码.

You can try this code to get Current Keyboard Language regional code.

这篇关于如何以编程方式在Android设备上获取当前的键盘语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆