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:kiwi.root.an2linuxclient.activities.MainSettingsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PreferenceManager.setDefaultValues(this, R.xml.main_settings_preferences, false);

    // Display the fragment as the main content.
    getFragmentManager().beginTransaction().replace(android.R.id.content, new SettingsFragment()).commit();
}

From source file:mobile.client.iot.pzalejko.iothome.MainActivity.java

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

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

    connectingTextView = (TextView) findViewById(R.id.connectingTextView);
    tempAlertValueText = (TextView) findViewById(R.id.tempAlertValueText);
    connection = new MqttServiceConnection(getApplicationContext(), connectingTextView);
    broadcaster = LocalBroadcastManager.getInstance(this);

    receiver = new InEventReceiver(this, broadcaster, connection);
}

From source file:dentex.youtube.downloader.menu.TutorialsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    BugSenseHandler.leaveBreadcrumb("TutorialsActivity_onCreate");
    this.setTitle(R.string.title_activity_tutorials);

    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);

    // Theme init
    Utils.themeInit(this);

    // Language init
    Utils.langInit(this);

    // Load default preferences values
    PreferenceManager.setDefaultValues(this, R.xml.tutorials, false);

    // Display the fragment as the main content.
    getFragmentManager().beginTransaction().replace(android.R.id.content, new TutorialsFragment()).commit();
    setupActionBar();//from w w  w.  j a va 2 s.  c o  m
}

From source file:com.tmendes.birthdaydroid.ContactListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.fragment_contact_list, container, false);

    this.ctx = container.getContext();

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

    this.birthdayData = BirthDayDataList.getBirthDayDataList(this.ctx);

    getPermissionToReadUserContacts();//from  w  w  w  . j a v  a  2 s . c  om

    this.adapter = new BirthDayArrayAdapter(this.ctx, this.birthdayData.getList());

    ListView listView = (ListView) v.findViewById(R.id.lvContacts);
    listView.setTextFilterEnabled(true);
    listView.setAdapter(this.adapter);

    inputSearch = (EditText) v.findViewById(R.id.inputSearch);
    getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    inputSearch.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
            // When user changed the Text
            adapter.getFilter().filter(cs.toString());
        }

        @Override
        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
        }

        @Override
        public void afterTextChanged(Editable arg0) {
            String text = inputSearch.getText().toString();
            adapter.getFilter().filter(text);
        }
    });

    this.updateSettings();

    return v;
}

From source file:com.stoneapp.ourvlemoodle2.activities.MainActivity.java

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

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

    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar);
    ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout);

    setSupportActionBar(toolbar);//from   w w w .j  a va  2 s . com

    viewPager.setAdapter(new TabPagerAdapter(getSupportFragmentManager()));

    tabLayout.setupWithViewPager(viewPager);

    String action = getIntent().getAction();
    if (action != null && action.equals(BuildConfig.APPLICATION_ID + ".ACTION_OPEN_EVENTS"))
        viewPager.setCurrentItem(1);

    // Create account, if needed
    CreateSyncAccount(this);
}

From source file:com.example.android.ennis.barrett.popularmovies.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i(TAG, "onCreate started");

    //Initialize default values for shared preferences
    PreferenceManager.setDefaultValues(this, R.xml.preferences, true);

    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//from  w  ww .j a va  2  s  .  c om
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setIcon(R.mipmap.ic_launcher);

    TMDbSyncAdapter.initializeSyncAdapter(this);

    if (findViewById(R.id.detail_container) != null) {
        Log.v(TAG, "Tablet layout");
        mTwoPane = true;
    }
}

From source file:ws.logv.trainmonitor.ui.MainActivity.java

@Override
protected synchronized void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.Theme_Sherlock);//w w  w .j a va 2s  .c  o  m

    super.onCreate(savedInstanceState);
    PreferenceManager.setDefaultValues(this, R.xml.settings, false);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    WindowMediator.setOnRefreshStateRequestHandler(new OnRefreshRequestStateHandler() {
        @Override
        public void onRefreshStart() {
            setProgressBarIndeterminateVisibility(true);
        }

        @Override
        public void onRefreshEnd() {
            setProgressBarIndeterminateVisibility(false);
        }
    });

    setContentView(R.layout.activity_main);

    mBus.postSticky(new ShowDisclaimerEvent());
}

From source file:com.emetophobe.permissionviewer.activities.MainActivity.java

/**
 * Initialize the main activity./* www.j  av a  2s  .  c o  m*/
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Make sure default preferences are initialized.
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);

    // Set up the toolbar.
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver,
            new IntentFilter(PermissionScanner.PERMISSION_INTENT));

    // Initialize the database the first time the application is run.
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (prefs.getBoolean(PREF_FIRST_RUN, true)) {
        new PermissionScanner(this).start();
        prefs.edit().putBoolean(PREF_FIRST_RUN, false).apply();
    } else {
        // Just display the view pager if the database has already been initialized.
        initViewPager();
    }
}

From source file:dentex.youtube.downloader.TutorialsActivity.java

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

    this.setTitle(R.string.title_activity_tutorials);

    settings = getSharedPreferences(PREFS_NAME, 0);

    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);

    // Theme init
    Utils.themeInit(this);

    // Language init
    Utils.langInit(this);

    // Load default preferences values
    PreferenceManager.setDefaultValues(this, R.xml.tutorials, false);

    // Display the fragment as the main content.
    getFragmentManager().beginTransaction().replace(android.R.id.content, new TutorialsFragment()).commit();
    setupActionBar();//from   ww w  .j  a  va  2 s .c  o m
}

From source file:net.olejon.mdapp.NotificationsFromSlvActivity.java

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

    // Settings/*from  w ww  .j a  va 2  s  .  c  o m*/
    PreferenceManager.setDefaultValues(mContext, R.xml.settings, false);

    // Connected?
    if (!mTools.isDeviceConnected()) {
        mTools.showToast(getString(R.string.device_not_connected), 1);

        finish();

        return;
    }

    // Notification manager
    mNotificationManagerCompat = NotificationManagerCompat.from(mContext);

    // Layout
    setContentView(R.layout.activity_notifications_from_slv);

    // Toolbar
    final Toolbar toolbar = (Toolbar) findViewById(R.id.notifications_from_slv_toolbar);
    toolbar.setTitle(getString(R.string.notifications_from_slv_title));

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // Progress bar
    mProgressBar = (ProgressBar) findViewById(R.id.notifications_from_slv_toolbar_progressbar);
    mProgressBar.setVisibility(View.VISIBLE);

    // Refresh
    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.notifications_from_slv_swipe_refresh_layout);
    mSwipeRefreshLayout.setColorSchemeResources(R.color.accent_blue, R.color.accent_green,
            R.color.accent_purple, R.color.accent_orange);

    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            getNotifications(false);
        }
    });

    // Recycler view
    mRecyclerView = (RecyclerView) findViewById(R.id.notifications_from_slv_cards);

    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setAdapter(new NotificationsFromSlvAdapter(mContext, new JSONArray()));
    mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));

    // Get notifications
    getNotifications(true);
}