In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use java to obtain the system language through the underlying interface of Android". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use java to get the system language through Android's underlying interface.
The cause of the matter is the need for multilingual processing when doing overseas projects. It has always been no problem for us to get the locale of the mobile phone through the Application.systemLanguage interface of Unity. But in the Android 9 operating system of Huawei phone, after switching to traditional Chinese, we found that the display was ChineseSimplified simplified Chinese through the interface of Unity.
At first we thought that the Unity engine might not be compatible, so we started to write java code to get the system language through the underlying Android interface.
Public String GetDeviceLanguage ()
{
Locale locale = Locale.getDefault ()
/ / > = 24 is Android 7.0 or high
If (Build.VERSION.SDK_INT > = Build.VERSION_CODES.N) {
Locale = getResources () .getConfiguration () .getLocales () .get (0)
}
String language = locale.getLanguage () + "-" + locale.getCountry ()
Return language
}
We use the above interface to find that when the mobile phone system is in traditional Chinese, we still get zh-cn. Even at the bottom of Android, you can't get it right. But the language displayed on the phone is indeed traditional Chinese. What should I do?
Since the display is in traditional Chinese, let's just deal with it according to the language displayed. There is such an interface at the bottom of java.
Locale.getDisplayCountry ()
Gets the displayed country. We found that it showed "China". All right, we get the DisplayCountry by writing java code, and then compare it with "China". If it is equal, it will be regarded as traditional Chinese.
At this point, I believe you have a deeper understanding of "how to use java to obtain the system language through Android's underlying interface". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.