Android Open Source - digital-ocean-swimmer My Application

From Project

Back to project page digital-ocean-swimmer.


The source code is released under:

MIT License

If you think the Android project digital-ocean-swimmer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.yassirh.digitalocean.utils;
//  www  .  j a  v  a2 s . c o m
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.preference.PreferenceManager;

import java.util.Locale;

public class MyApplication extends Application{

    private static Context context;

    public void onCreate(){
        MyApplication.context = getApplicationContext();
        SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);

        Configuration config = getBaseContext().getResources().getConfiguration();

        String lang = settings.getString("pref_locale", "");
        if (! "".equals(lang) && ! config.locale.getLanguage().equals(lang))
            locale = new Locale(lang);
            config.locale = locale;
            getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());

    public static Context getAppContext() {
        return MyApplication.context;
    private Locale locale = null;

    public void onConfigurationChanged(Configuration newConfig)
        if (locale != null)
            newConfig.locale = locale;
            getBaseContext().getResources().updateConfiguration(newConfig, getBaseContext().getResources().getDisplayMetrics());


Java Source Code List