小编Vik*_*yal的帖子

如何在不使用GPS的情况下获取我的Android设备国家代码?

Android移动设备实际上确实知道它在哪里 - 但有没有办法通过国家代码或国家/地区名称来检索国家/地区?

无需知道确切的GPS位置 - 国家代码或名称就足够了,我正在使用以下代码:

 String locale = context.getResources().getConfiguration().locale.getCountry(Locale.getDefault());      
 System.out.println("country = "+locale);
Run Code Online (Sandbox Code Playgroud)

但它给了我"美国"代码,
但我的设备保存在印度; 有没有办法找到设备当前国家代码而不使用GPS或网络提供商.因为我正在使用平板电脑 提前致谢.

android locale

51
推荐指数
7
解决办法
9万
查看次数

如何将 UTF-16 编码类型字符串设置为 android 中的 TextView

我是一名新的 Android 开发人员,我有一个 UTF-16LE 编码的字符串。我想在我的活动的 Textview 中打印该字符串。但是,印地语中的字符串。当我得到字符串的 Sysout 时,它会显示写入格式和单词(例如:05-07 12:31:53.050: I/System.out(22887): str = ???? ?????, str = ? ?? ?????????? / ?????)。但在设备的 TextView 中,它只显示 BOXES。
这是代码:-

 String myString = ??? ?????????? / ???? ?????;
 String correct = null;
try {
    byte[] utf16le = myString .getBytes("UTF-16");
    correct = new String(utf16le, "UTF-16");
} catch (UnsupportedEncodingException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
System.out.println("str = "+correct);
Run Code Online (Sandbox Code Playgroud)

任何帮助表示赞赏。

谢谢

android

5
推荐指数
0
解决办法
1832
查看次数

标签 统计

android ×2

locale ×1