1. 程式人生 > >Android判斷國家以及系統當前的語言

Android判斷國家以及系統當前的語言

判斷國家:

中文:getResources().getConfiguration().locale.getCountry().equals("CN")

英文(英式):getResources().getConfiguration().locale.getCountry().equals("UK")


獲取當前系統設定的語言:

Locale.getDefault().getLanguage()

例如判斷當前系統語言是不是 阿拉伯語(ar):

import java.util.Locale;

if (Locale.getDefault().getLanguage() != null  && Locale.getDefault().getLanguage().trim().equals("ar")){
            。。。。。。
   }