當前位置: 首頁>>代碼示例>>Java>>正文


Java Resources.updateConfiguration方法代碼示例

本文整理匯總了Java中android.content.res.Resources.updateConfiguration方法的典型用法代碼示例。如果您正苦於以下問題:Java Resources.updateConfiguration方法的具體用法?Java Resources.updateConfiguration怎麽用?Java Resources.updateConfiguration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.res.Resources的用法示例。


在下文中一共展示了Resources.updateConfiguration方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkLanguage

import android.content.res.Resources; //導入方法依賴的package包/類
private void checkLanguage() {

        SharedPreferences sharedPreferences = this.getSharedPreferences("set", MODE_PRIVATE);
        /**
         * 獲取係統配置
         */
        Resources resources = getResources();
        DisplayMetrics dm = resources.getDisplayMetrics();
        Configuration config = resources.getConfiguration();


        if (LANGUAGE_CN.equals(sharedPreferences.getString("language", "0"))) {

            config.locale = Locale.SIMPLIFIED_CHINESE;
            resources.updateConfiguration(config, dm);
        } else if (LANGUAGE_EN.equals(sharedPreferences.getString("language", "0"))) {

            config.locale = Locale.ENGLISH;
            resources.updateConfiguration(config, dm);
        } else {

            config.locale = Locale.SIMPLIFIED_CHINESE;
            resources.updateConfiguration(config, dm);
        }

    }
 
開發者ID:stewForAni,項目名稱:Lamp,代碼行數:27,代碼來源:WifiConnectActivity.java

示例2: onCreate

import android.content.res.Resources; //導入方法依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();
    Resources resources = getResources();
    DisplayMetrics dm = resources.getDisplayMetrics();
    Configuration config = resources.getConfiguration();
    // 應用用戶選擇語言
    String language = SPUtil.getInstance(this).getLanguage();
    if ("".equals(language)){
        language =Locale.getDefault().getLanguage();
    }
    if (language.equals(SPUtil.LANGUAGE_CHINESE)) {
        config.setLocale(Locale.getDefault());
    } else  {
        config.setLocale(Locale.ENGLISH);
    }
    resources.updateConfiguration(config, dm);

    mContext=getApplicationContext();
}
 
開發者ID:EggUncle,項目名稱:XposedNavigationBar,代碼行數:21,代碼來源:MyApplication.java

示例3: changeLanguage

import android.content.res.Resources; //導入方法依賴的package包/類
public static void changeLanguage(Context context) {
    Resources resources = context.getResources();
    DisplayMetrics dm = resources.getDisplayMetrics();
    Configuration config = resources.getConfiguration();
    switch (SharedPreManager.getInstance().getLanguage(context)) {
        case Constant.LANGUAGE_CHINA:
            config.locale = Locale.SIMPLIFIED_CHINESE;
            break;
        case Constant.LANGUAGE_ENGLISH:
            config.locale = Locale.ENGLISH;
            break;
        case Constant.LANGUAGE_DEFAULT:
            config.locale = Locale.getDefault();
            break;
    }
    // 應用用戶選擇語言
    resources.updateConfiguration(config, dm);
}
 
開發者ID:Yuanhongliang,項目名稱:HLOLI,代碼行數:19,代碼來源:App.java

示例4: hasDictionary

import android.content.res.Resources; //導入方法依賴的package包/類
private boolean hasDictionary(Locale locale, Context ctx) {
    Resources res = getResources();
    Configuration conf = res.getConfiguration();
    Locale saveLocale = conf.locale;
    boolean haveDictionary = false;
    conf.locale = locale;
    res.updateConfiguration(conf, res.getDisplayMetrics());

    //somewhat a hack. But simply querying the dictionary will always return an English
    //dictionary in KP2A so if we get a dict, we wouldn't know if it's language specific 
    if (locale.getLanguage().equals("en"))
    {
    	haveDictionary = true;
    }
    else 
    {
        BinaryDictionary plug = PluginManager.getDictionary(getApplicationContext(), locale.getLanguage());
        if (plug != null) {
        	plug.close();
        	haveDictionary = true;
        }
    }
    conf.locale = saveLocale;
    res.updateConfiguration(conf, res.getDisplayMetrics());
    return haveDictionary;
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:27,代碼來源:InputLanguageSelection.java

示例5: runInLocale

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * Execute {@link #job(Resources)} method in specified system locale exclusively.
 *
 * @param res the resources to use.
 * @param newLocale the locale to change to. Run in system locale if null.
 * @return the value returned from {@link #job(Resources)}.
 */
public T runInLocale(final Resources res, final Locale newLocale) {
    synchronized (sLockForRunInLocale) {
        final Configuration conf = res.getConfiguration();
        if (newLocale == null || newLocale.equals(conf.locale)) {
            return job(res);
        }
        final Locale savedLocale = conf.locale;
        try {
            conf.locale = newLocale;
            res.updateConfiguration(conf, null);
            return job(res);
        } finally {
            conf.locale = savedLocale;
            res.updateConfiguration(conf, null);
        }
    }
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:25,代碼來源:RunInLocale.java

示例6: changeLocale

import android.content.res.Resources; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public static void changeLocale(String locale) {
    Context context = InstrumentationRegistry.getInstrumentation()
            .getTargetContext();

    Resources res = context.getApplicationContext().getResources();
    Configuration config = res.getConfiguration();


    config.setLocale(new Locale(locale));
    if (SDK_INT >= 25) {
        context.createConfigurationContext(config);
    } else {
        res.updateConfiguration(config, res.getDisplayMetrics());
    }
}
 
開發者ID:mozilla-mobile,項目名稱:firefox-tv,代碼行數:17,代碼來源:SwitchLocaleTest.java

示例7: updateConfigurationForNightMode

import android.content.res.Resources; //導入方法依賴的package包/類
private boolean updateConfigurationForNightMode(int mode) {
    Resources res = this.mContext.getResources();
    Configuration conf = res.getConfiguration();
    int currentNightMode = conf.uiMode & 48;
    int newNightMode = 0;
    switch (mode) {
        case 1:
            newNightMode = 16;
            break;
        case 2:
            newNightMode = 32;
            break;
    }
    if (currentNightMode == newNightMode) {
        return false;
    }
    conf.uiMode = (conf.uiMode & -49) | newNightMode;
    res.updateConfiguration(conf, null);
    return true;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:21,代碼來源:AppCompatDelegateImplV14.java

示例8: initTextSize

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * 使其係統更改字體大小無效
 */
private void initTextSize() {
    Resources res = getResources();
    Configuration config = new Configuration();
    config.setToDefaults();
    res.updateConfiguration(config, res.getDisplayMetrics());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:CloudReaderApplication.java

示例9: setLocale

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * Set the app to use the given locale. Useful for testing translations. This is normally
 * not needed because the device locale is applied automatically.
 * @param context - context from which to get resources
 * @param locale - the locale to use
 */
public static void setLocale(@NonNull Context context, @NonNull Locale locale) {
    Locale.setDefault(locale);
    Resources res = context.getResources();
    DisplayMetrics dm = res.getDisplayMetrics();
    android.content.res.Configuration conf = res.getConfiguration();
    conf.locale = Locale.getDefault();
    res.updateConfiguration(conf, dm);
}
 
開發者ID:TryGhost,項目名稱:Ghost-Android,代碼行數:15,代碼來源:AppUtils.java

示例10: getResources

import android.content.res.Resources; //導入方法依賴的package包/類
@Override
public Resources getResources() {
    //保持字體不變
    Resources res = super.getResources();
    Configuration config = new Configuration();
    config.setToDefaults();
    res.updateConfiguration(config, res.getDisplayMetrics());
    return res;
}
 
開發者ID:YunzhanghuOpen,項目名稱:redpacketui-open,代碼行數:10,代碼來源:RPBaseActivity.java

示例11: updateConfiguration

import android.content.res.Resources; //導入方法依賴的package包/類
private void updateConfiguration() {
    if (JarApplication.getInstance() != null && JarApplication.getInstance().getResources() != null) {
        Resources superRes = JarApplication.getInstance().getResources();
        Configuration configuration = superRes.getConfiguration();
        DisplayMetrics displayMetrics = superRes.getDisplayMetrics();
        JarResources jarResources = getOverrideResources();
        if (jarResources != null) {
            Resources resources = jarResources.getResources();
            if (resources != null && configuration != null && displayMetrics != null) {
                resources.updateConfiguration(configuration, displayMetrics);
            }
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:15,代碼來源:ProxyFragment.java

示例12: applyLanguageForContext

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * Setting {@link Locale} for {@link Context}.
 */
@NonNull
public static Context applyLanguageForContext(@NonNull Context context, @NonNull Locale locale) {
    Resources resources = context.getResources();
    Configuration config = resources.getConfiguration();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        config.setLocale(locale);
        return context.createConfigurationContext(config);
    } else {
        config.locale = locale;
        resources.updateConfiguration(config, resources.getDisplayMetrics());
        return context;
    }
}
 
開發者ID:WeiXinqiao,項目名稱:Recognize-it,代碼行數:17,代碼來源:AlbumUtils.java

示例13: setLocale

import android.content.res.Resources; //導入方法依賴的package包/類
public  void setLocale(String lang) {
    Locale myLocale = new Locale(lang);
    Resources res = getResources();
    DisplayMetrics dm = res.getDisplayMetrics();
    Configuration conf = res.getConfiguration();
    conf.locale = myLocale;
    res.updateConfiguration(conf, dm);
    Intent refresh = new Intent(getContext(), MainActivity.class);
    startActivity(refresh);
    getActivity().finish();
}
 
開發者ID:jcolladosp,項目名稱:PimPam,代碼行數:12,代碼來源:SettingsFragment.java

示例14: getResources

import android.content.res.Resources; //導入方法依賴的package包/類
@Override
public Resources getResources() {
    Resources res = super.getResources();
    if (res.getConfiguration().fontScale != 1) {//非默認值
        Configuration newConfig = new Configuration();
        newConfig.setToDefaults();//設置默認
        res.updateConfiguration(newConfig, res.getDisplayMetrics());
    }
    return res;
}
 
開發者ID:quickhybrid,項目名稱:quickhybrid-android,代碼行數:11,代碼來源:FrmApplication.java

示例15: changeLanguage

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * Нөөц дэх хэлний файлууд уншиж текстүүд орчуулах
 *
 * @param lang res/values/strings xml файлаас ямар хэл сонгохыг заана
 */
private void changeLanguage(String lang) {
    Resources res = getApplicationContext().getResources();
    DisplayMetrics dm = res.getDisplayMetrics();
    android.content.res.Configuration conf = res.getConfiguration();
    conf.locale = new Locale(lang);
    res.updateConfiguration(conf, dm);
    prefManager.setLanguage(lang.toUpperCase());
    Intent intent = new Intent(ActivitySplashScreen.this, ActivityWelcome.class);
    startActivity(intent);
    finish();
}
 
開發者ID:techstar-cloud,項目名稱:techstar-shop,代碼行數:17,代碼來源:ActivitySplashScreen.java


注:本文中的android.content.res.Resources.updateConfiguration方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。