Example usage for android.preference PreferenceManager setDefaultValues

List of usage examples for android.preference PreferenceManager setDefaultValues

Introduction

In this page you can find the example usage for android.preference PreferenceManager setDefaultValues.

Prototype

public static void setDefaultValues(Context context, @XmlRes int resId, boolean readAgain) 

Source Link

Document

Sets the default values from an XML preference file by reading the values defined by each Preference item's android:defaultValue attribute.

Usage

From source file:com.ofalvai.bpinfo.ui.settings.SettingsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    BpInfoApplication.injector.inject(this);

    setupActionBar();/* w  ww. jav  a  2s  .co  m*/

    addPreferencesFromResource(R.xml.pref_general);
    PreferenceManager.setDefaultValues(this, R.xml.pref_general, false);

    bindPreferenceSummaryToValue(findPreference(getString(R.string.pref_key_language)));
    bindPreferenceSummaryToValue(findPreference(getString(R.string.pref_key_data_source)));

}

From source file:org.catrobat.catroid.ui.MainMenuActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!Utils.checkForExternalStorageAvailableAndDisplayErrorIfNot(this)) {
        return;// www .j a v  a2s .com
    }
    initializeFacebookSdk();

    PreferenceManager.setDefaultValues(this, R.xml.preferences, true);
    UtilUi.updateScreenWidthAndHeight(this);

    if (STANDALONE_MODE) {
        /*requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
           WindowManager.LayoutParams.FLAG_FULLSCREEN);*/
        getActionBar().hide();
        setContentView(R.layout.activity_main_menu_splashscreen);
        unzipProgram();
    } else {
        setContentView(R.layout.activity_main_menu);

        final ActionBar actionBar = getActionBar();
        actionBar.setDisplayUseLogoEnabled(true);
        actionBar.setHomeButtonEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(false);
        actionBar.setTitle(R.string.app_name);

        findViewById(R.id.main_menu_button_continue).setEnabled(false);

        // Load external project from URL or local file system.
        Uri loadExternalProjectUri = getIntent().getData();
        getIntent().setData(null);

        if (loadExternalProjectUri != null) {
            loadProgramFromExternalSource(loadExternalProjectUri);
        }
    }
}

From source file:com.lcl.thumbweather.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.e("-LCL-", "MainActivity:onCreated.");
    // Initialize the associated SharedPreferences file with default values
    PreferenceManager.setDefaultValues(this, R.xml.prefs, false);

    darkTheme = false;/*from  w w w . j  a  v  a2s  .co m*/
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (prefs.getBoolean("darkTheme", false)) {
        setTheme(R.style.AppTheme_NoActionBar_Dark);
        darkTheme = true;
    }

    // ? activity
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scrolling);
    appView = findViewById(R.id.viewApp);

    progressDialog = new ProgressDialog(MainActivity.this);

    //  toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    //
    toolbar.setTitle("");
    setSupportActionBar(toolbar);
    //Logo
    toolbar.setLogo(R.mipmap.umbrella_white);
    if (darkTheme) {
        toolbar.setPopupTheme(R.style.AppTheme_PopupOverlay_Dark);
    }

    // ? textboxes
    todayTemperature = (TextView) findViewById(R.id.todayTemperature);
    todayDescription = (TextView) findViewById(R.id.todayDescription);
    todayWind = (TextView) findViewById(R.id.todayWind);
    todayPressure = (TextView) findViewById(R.id.todayPressure);
    todayHumidity = (TextView) findViewById(R.id.todayHumidity);
    todaySunrise = (TextView) findViewById(R.id.todaySunrise);
    todaySunset = (TextView) findViewById(R.id.todaySunset);
    todayIcon = (TextView) findViewById(R.id.todayIcon);
    cityIs = (TextView) findViewById(R.id.city);
    weatherFont = Typeface.createFromAsset(this.getAssets(), "fonts/weather.ttf");
    todayIcon.setTypeface(weatherFont);

    // ? viewPager
    viewPager = (ViewPager) findViewById(R.id.viewPager);
    tabLayout = (TabLayout) findViewById(R.id.tabs);

    destroyed = false;

    initMappings();

    // ?
    preloadWeather();

    // 
    AlarmReceiver.setRecurringAlarm(this);
}

From source file:nl.spellenclubeindhoven.dominionshuffle.SelectActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.select);//w  w w .j  a v  a  2s.c  o  m

    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);

    application = (Application) getApplication();
    dataReader = application.getDataReader();
    cardSelector = application.getCardSelector();

    TabHost tabs = getTabHost();

    TabHost.TabSpec spec = tabs.newTabSpec("inex");
    spec.setContent(R.id.inex_fastscrollview);
    spec.setIndicator(getResources().getString(R.string.tab_select),
            getResources().getDrawable(R.drawable.select_tab));
    tabs.addTab(spec);

    spec = tabs.newTabSpec("constraint");
    spec.setContent(R.id.constraint_fastscrollview);
    spec.setIndicator(getResources().getString(R.string.tab_constraints),
            getResources().getDrawable(R.drawable.limits_tab));
    tabs.addTab(spec);

    spec = tabs.newTabSpec("generate");
    spec.setContent(R.id.generateButtons);
    spec.setIndicator(getResources().getString(R.string.tab_generate),
            getResources().getDrawable(R.drawable.shuffle_tab));
    tabs.addTab(spec);

    inexFastScrollView = ((CustomFastScrollView) findViewById(R.id.inex_fastscrollview));
    inexFastScrollView.setOnScrollListener(this);

    constraintFastScrollView = ((CustomFastScrollView) findViewById(R.id.constraint_fastscrollview));
    constraintFastScrollView.setOnScrollListener(this);

    groupsAndCards = new LinkedList<Object>();

    inExAdapter = new InExAdapter(this, groupsAndCards, cardSelector, getPreferredCardComparator());
    inexList = (ListView) findViewById(R.id.inexList);
    inexList.setAdapter(inExAdapter);
    inexList.setOnItemClickListener(onItemClickListener);
    inexList.setOnItemLongClickListener(onItemLongClickListener);

    constraintList = (ListView) findViewById(R.id.constraintList);
    constraintAdapter = new ConstraintAdapter(this, groupsAndCards, cardSelector, getPreferredCardComparator());
    constraintList.setAdapter(constraintAdapter);
    constraintList.setOnItemClickListener(onItemClickListener);
    constraintList.setOnTouchListener(onConstraintListTouchListener);
    constraintList.setOnKeyListener(onConstraintKeyListener);
    constraintList.setOnItemLongClickListener(onItemLongClickListener);

    Button generateButton = (Button) findViewById(R.id.generateButton);
    generateButton.setOnClickListener(onGenerateClickListener);

    Button lastResultButton = (Button) findViewById(R.id.lastResultButton);
    lastResultButton.setOnClickListener(onLastResultClickListener);

    if (savedInstanceState != null) {
        dialogMessage = savedInstanceState.getString("dialogMessage");
        if (dataReader.getData() != null) {
            selectedGroup = dataReader.getData().getGroup(savedInstanceState.getString("selectedGroup"));
        }
    }

    SharedPreferences prefs = getPreferences(MODE_PRIVATE);

    dialogMimimumCount = getResources().getStringArray(R.array.minumum_items_conditional).length;
    dialogMaximumCount = getResources().getStringArray(R.array.maximum_items).length;
}

From source file:com.tlongdev.bktf.ui.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);

    BptfApplication application = (BptfApplication) getApplication();
    application.getActivityComponent().inject(this);
    application.startTracking();/*from   w w  w.  ja  v a  2s.  co  m*/

    //Set the default values for all preferences when the app is first loaded
    PreferenceManager.setDefaultValues(this, R.xml.pref_general, false);

    //Setup the drawer
    mDrawerLayout.setStatusBarBackgroundColor(ContextCompat.getColor(this, R.color.primary_dark));

    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    //The navigation view
    mNavigationView.setNavigationItemSelectedListener(navigationListener);

    mNavigationDrawerManager.attachView(mNavigationView.getHeaderView(0));
    mNavigationDrawerManager.setUserMenuItem(mNavigationView.getMenu().findItem(R.id.nav_user));

    //Check if there is a fragment to be restored
    if (savedInstanceState == null) {
        mNavigationView.getMenu().getItem(0).setChecked(true);
        // Select either the default item (0) or the last selected item.
        switchFragment(0);
    }
}

From source file:com.heightechllc.breakify.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Set up the default values for the preferences
    PreferenceManager.setDefaultValues(this, R.xml.timer_durations_preferences, true);
    PreferenceManager.setDefaultValues(this, R.xml.alarm_preferences, true);
    PreferenceManager.setDefaultValues(this, R.xml.scheduled_start_preferences, true);
    PreferenceManager.setDefaultValues(this, R.xml.misc_preferences, true);

    setContentView(R.layout.activity_main);

    // If the user presses the device's volume keys, we want to adjust the alarm volume
    setVolumeControlStream(AlarmRinger.STREAM_TYPE);

    ///*from   ww  w.  j av a2s  .c o  m*/
    // Set up components
    //
    stateLbl = (TextView) findViewById(R.id.state_lbl);
    timeLbl = (TextView) findViewById(R.id.time_lbl);
    startStopLbl = (TextView) findViewById(R.id.start_stop_lbl);

    circleTimer = (CircleTimerView) findViewById(R.id.circle_timer);
    circleTimer.setOnClickListener(this);
    circleTimer.setTimeDisplay(timeLbl);

    resetBtn = (ImageButton) findViewById(R.id.reset_btn);
    resetBtn.setOnClickListener(this);

    skipBtn = (Button) findViewById(R.id.skip_btn);
    skipBtn.setOnClickListener(this);

    sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);

    // Check if analytics are enabled in preferences
    if (sharedPref.getBoolean(MiscSettingsFragment.KEY_ANALYTICS_ENABLED, false) && !BuildConfig.DEBUG)
        mixpanel = MixpanelAPI.getInstance(this, "d78a075fc861c288e24664a8905a6698");

    // Handle the intent
    boolean shouldRestoreSavedTimer = handleIntent(getIntent());

    if (shouldRestoreSavedTimer) {
        // Restore saved timer state
        restoreSavedTimer();
    }

    // Add the custom alarm tones to the phone's storage, if they weren't copied yet.
    // Works on a separate thread.
    if (!sharedPref.getBoolean(CustomAlarmTones.PREF_KEY_RINGTONES_COPIED, false))
        CustomAlarmTones.installToStorage(this);
}

From source file:io.github.runassudo.ptoffline.activities.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //      enableStrictMode();
    setContentView(R.layout.activity_main);

    PreferenceManager.setDefaultValues(MainActivity.this, R.xml.preferences, false);

    final TransportNetwork network = Preferences.getTransportNetwork(this);

    // Handle Toolbar
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//from ww  w . j ava 2 s.  c  om

    // Accounts aka TransportNetworks
    accountHeader = new AccountHeaderBuilder().withActivity(this)
            .withHeaderBackground(R.drawable.account_header_background).withSelectionListEnabled(false)
            .withThreeSmallProfileImages(true)
            .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {
                @Override
                public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) {
                    if (currentProfile) {
                        openPickNetworkProviderActivity();
                        return true;
                    } else if (profile != null && profile instanceof ProfileDrawerItem) {
                        TransportNetwork network = (TransportNetwork) ((ProfileDrawerItem) profile).getTag();
                        if (network != null) {
                            // save new network
                            Preferences.setNetworkId(getContext(), network.getId());

                            // notify everybody of this change
                            onNetworkProviderChanged();
                        }
                    }
                    return false;
                }
            }).withOnAccountHeaderSelectionViewClickListener(
                    new AccountHeader.OnAccountHeaderSelectionViewClickListener() {
                        @Override
                        public boolean onClick(View view, IProfile profile) {
                            openPickNetworkProviderActivity();
                            return true;
                        }
                    })
            .build();

    // Drawer
    drawer = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withAccountHeader(accountHeader)
            .addDrawerItems(getDrawerItem(DirectionsFragment.TAG, R.drawable.ic_menu_directions),
                    getDrawerItem(RecentTripsFragment.TAG, R.drawable.ic_tab_recents),
                    getDrawerItem(DeparturesFragment.TAG, R.drawable.ic_action_departures),
                    getDrawerItem(NearbyStationsFragment.TAG, R.drawable.ic_tab_stations),
                    new DividerDrawerItem(), getDrawerItem(SettingsFragment.TAG, R.drawable.ic_action_settings),
                    getDrawerItem(TransportrChangeLog.TAG, R.drawable.ic_action_changelog),
                    getDrawerItem(AboutMainFragment.TAG, R.drawable.ic_action_about))
            .withOnDrawerListener(new Drawer.OnDrawerListener() {
                @Override
                public void onDrawerOpened(View drawerView) {
                    KeyboardUtil.hideKeyboard(MainActivity.this);
                }

                @Override
                public void onDrawerClosed(View drawerView) {
                }

                @Override
                public void onDrawerSlide(View drawerView, float slideOffset) {
                }
            }).withFireOnInitialOnClick(false).withSavedInstance(savedInstanceState).build();

    if (savedInstanceState == null) {
        // make the user select a transport network, if none is selected
        ensureTransportNetworkAvailable(network);

        // update drawer items to reflect network capabilities
        updateDrawerItems(network);

        // show network name in toolbar subtitle
        if (network != null) {
            toolbar.setSubtitle(network.getName());
        }

        // add initial fragment
        getSupportFragmentManager().beginTransaction()
                .add(R.id.fragment_container, new DirectionsFragment(), DirectionsFragment.TAG).commit();
    } else {
        // restore toolbar title
        String tag = getCurrentFragmentTag();
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null)
            actionBar.setTitle(getFragmentName(tag));

        if (network != null && !tag.equals(AboutMainFragment.TAG) && !tag.equals(SettingsFragment.TAG)) {
            toolbar.setSubtitle(network.getName());
        }

        processIntent();
    }

    getSupportFragmentManager().addOnBackStackChangedListener(this);

    // add transport networks to header
    addAccounts(network);

    // show Changelog if something is new
    TransportrChangeLog cl = new TransportrChangeLog(this, Preferences.darkThemeEnabled(this));
    if (cl.isFirstRun() && !cl.isFirstRunEver()) {
        cl.getLogDialog().show();
    }

    // create Android 7.1 shortcut
    registerNougatShortcuts();

    // Ensure we have read permission
    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        // Should we show an explanation?
        if (ActivityCompat.shouldShowRequestPermissionRationale(this,
                Manifest.permission.READ_EXTERNAL_STORAGE)) {
            Toast.makeText(this, R.string.permission_denied_read, Toast.LENGTH_LONG).show();
        } else {
            Toast.makeText(this, R.string.permission_explanation_read, Toast.LENGTH_LONG).show();
            ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE },
                    MainActivity.PR_READ_EXTERNAL_STORAGE);
        }
    }
}

From source file:org.restcomm.android.olympus.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Log.i(TAG, "%% onCreate");
    Log.i(TAG, "Olympus Version: " + APP_VERSION);

    // For TestFairy troubleshooting. IMPORTANT: remove for production apps, as TestFairy sends logs, screenshots, etc to their servers
    //TestFairy.begin(this, "#TESTFAIRY_APP_TOKEN");
    TestFairy.begin(this, "52d3ee1de1b7681d1fcbbc3295b2b86a0aa43fcc");

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from   ww  w  .j  a  v  a2  s. com*/
    // TODO set proper image at xhdpi with 48x48
    toolbar.setNavigationIcon(R.drawable.bar_icon_24dp);
    toolbar.setTitle(getTitle());

    listFragment = (MainFragment) getSupportFragmentManager().findFragmentById(R.id.item_list);

    btnAdd = (FloatingActionButton) findViewById(R.id.imageButton_add);
    btnAdd.setOnClickListener(this);

    alertDialog = new AlertDialog.Builder(MainActivity.this, R.style.SimpleAlertStyle).create();

    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    prefs = PreferenceManager.getDefaultSharedPreferences(this);

    // preferences
    prefs.registerOnSharedPreferenceChangeListener(this);

    checkPermissions();
    // No longer needed, we'll change with toast
    // set it to wifi by default to avoid the status message when starting with wifi
    //previousConnectivityStatus = RCConnectivityStatus.RCConnectivityStatusWiFi;
}

From source file:de.tap.easy_xkcd.Activities.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    prefHelper = new PrefHelper(this);
    setTheme(prefHelper.getTheme());/*from w  w  w.j  av  a2 s .  c om*/
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    PreferenceManager.setDefaultValues(this, R.xml.pref_alt_sharing, false);

    instance = this;
    customTabActivityHelper = new CustomTabActivityHelper();

    if (savedInstanceState == null) {
        if (prefHelper.getNotificationInterval() != 0) {
            WakefulIntentService.scheduleAlarms(new ComicListener(), this, true);
        } else {
            WakefulIntentService.cancelAlarms(this);
        }
    }

    fullOffline = prefHelper.fullOfflineEnabled();
    fullOfflineWhatIf = prefHelper.fullOfflineWhatIf();
    boolean whatIfIntent = false;

    //Check for intents
    switch (getIntent().getAction()) {
    case Intent.ACTION_VIEW:
        if (getIntent().getDataString().contains("what")) {
            WhatIfActivity.WhatIfIndex = (getNumberFromUrl(getIntent().getDataString(), 1));
            prefHelper.setLastWhatIf(WhatIfActivity.WhatIfIndex);
            whatIfIntent = true;
            WhatIfFragment.newIntent = true;
        } else {
            prefHelper.setLastComic(getNumberFromUrl(getIntent().getDataString(), 0));
        }
        break;
    case COMIC_INTENT:
        int number = getIntent().getIntExtra("number", 0);
        prefHelper.setLastComic(number);
        break;
    case WHATIF_INTENT:
        WhatIfActivity.WhatIfIndex = getIntent().getIntExtra("number", 0);
        prefHelper.setLastWhatIf(WhatIfActivity.WhatIfIndex);
        whatIfIntent = true;
        WhatIfFragment.newIntent = true;
        break;
    }
    //On Lollipop, change the app's icon in the recents app screen
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
            && !getIntent().getAction().equals(Intent.ACTION_VIEW)) {
        TypedValue typedValue = new TypedValue();
        Resources.Theme theme = getTheme();
        theme.resolveAttribute(R.attr.colorPrimary, typedValue, true);
        int color = typedValue.data;
        Bitmap ic = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_easy_xkcd_recents);
        ActivityManager.TaskDescription description = new ActivityManager.TaskDescription("Easy xkcd", ic,
                color);
        setTaskDescription(description);
        if (!prefHelper.colorNavbar())
            getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.ColorPrimaryBlack));
    }
    setSupportActionBar(toolbar);
    TypedValue typedValue2 = new TypedValue();
    getTheme().resolveAttribute(R.attr.colorPrimary, typedValue2, true);
    toolbar.setBackgroundColor(typedValue2.data);
    if (savedInstanceState == null)
        toolbar.setAlpha(0);

    mDrawer.setDrawerListener(mDrawerToggle);
    mDrawerToggle = setupDrawerToggle();
    if (prefHelper.nightThemeEnabled()) {
        mNavView.setBackgroundColor(ContextCompat.getColor(this, R.color.background_material_dark));
        toolbar.setPopupTheme(R.style.ThemeOverlay_AppCompat);
    }
    setupDrawerContent(mNavView);

    if (savedInstanceState == null) {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                prefHelper.showRateSnackbar(MainActivity.this.getPackageName(), MainActivity.this, mFab);
                prefHelper.showSurveySnackbar(MainActivity.this, mFab);
                prefHelper.showFeatureSnackbar(MainActivity.this, mFab);
            }
        }, 1500);
    }

    //Load fragment
    if (prefHelper.isOnline(this) | fullOffline | fullOfflineWhatIf) {
        MenuItem item;
        if (savedInstanceState != null) {
            //Get last loaded fragment
            mCurrentFragment = savedInstanceState.getInt(SAVED_INSTANCE_CURRENT_FRAGMENT);
            item = mNavView.getMenu().findItem(mCurrentFragment);
        } else {
            if (!whatIfIntent && fullOffline | prefHelper.isOnline(this)) {
                item = mNavView.getMenu().findItem(R.id.nav_browser);
            } else {
                item = mNavView.getMenu().findItem(R.id.nav_whatif);
            }
        }
        boolean showOverview = false;
        if (savedInstanceState != null)
            showOverview = savedInstanceState.getBoolean(OVERVIEW_TAG, false);
        else {
            overViewLaunch = prefHelper.launchToOverview();
        }
        selectDrawerItem(item, showOverview);
    } else if ((mCurrentFragment != R.id.nav_favorites)) { //Don't show the dialog if the user is currently browsing his favorites or full offline is enabled
        AlertDialog.Builder mDialog = new AlertDialog.Builder(this, prefHelper.getDialogTheme());
        mDialog.setMessage(R.string.no_connection)
                .setPositiveButton(R.string.no_connection_retry, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                        startActivity(getIntent());
                    }
                }).setCancelable(false);
        if (Favorites.getFavoriteList(this).length != 0) {
            mDialog.setNegativeButton(R.string.no_connection_favorites, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    MenuItem m = mNavView.getMenu().findItem(R.id.nav_favorites);
                    selectDrawerItem(m, false);
                }
            });
        }
        mDialog.show();
    }
}

From source file:au.org.ala.fielddata.mobile.MobileFieldDataDashboard.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Only show the splash screen on startup, and if the variant has been configured to do so.
    if (savedInstanceState == null && getResources().getBoolean(R.bool.show_splash_screen)) {

        showSplashScreen(getResources().getInteger(R.integer.splash_screen_duration));
    }//from w ww .jav  a2 s .co  m
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.activity_mobile_data_dashboard);
    getSupportActionBar().setDisplayUseLogoEnabled(true);
    getSupportActionBar().setLogo(R.drawable.ic_launcher);

    preferences = new Preferences(this);
    PreferenceManager.setDefaultValues(getApplicationContext(), R.xml.preference1, true);
    PreferenceManager.setDefaultValues(getApplicationContext(), R.xml.network_preferences, true);

    status = (TextView) findViewById(R.id.status);

    getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    String[] titles = getResources().getStringArray(R.array.tab_titles);

    viewPager = (ViewPager) findViewById(R.id.tabContent);
    TabsAdapter tabsAdapter = new TabsAdapter(this, viewPager);
    viewPager.setAdapter(tabsAdapter);

    int selectedTabIndex = 0;
    if (savedInstanceState != null) {
        askedAboutGPS = savedInstanceState.getBoolean(GPS_QUESTION_BUNDLE_KEY);
        redirectedToLogin = savedInstanceState.getBoolean(REDIRECTED_TO_LOGIN_BUNDLE_KEY);
        selectedTabIndex = savedInstanceState.getInt(SELECTED_TAB_BUNDLE_KEY, 0);
    }
    selectedTabIndex = getIntent().getIntExtra(SELECTED_TAB_BUNDLE_KEY, selectedTabIndex);

    for (int i = 0; i < titles.length; i++) {
        String title = titles[i];
        ActionBar.Tab tab = getSupportActionBar().newTab();
        tab.setText(title);
        tab.setTabListener(tabsAdapter);
        getSupportActionBar().addTab(tab);
    }

    getSupportActionBar().setSelectedNavigationItem(selectedTabIndex);

}