当前位置: 首页>>代码示例>>Java>>正文


Java PreferenceManager.setDefaultValues方法代码示例

本文整理汇总了Java中android.preference.PreferenceManager.setDefaultValues方法的典型用法代码示例。如果您正苦于以下问题:Java PreferenceManager.setDefaultValues方法的具体用法?Java PreferenceManager.setDefaultValues怎么用?Java PreferenceManager.setDefaultValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.preference.PreferenceManager的用法示例。


在下文中一共展示了PreferenceManager.setDefaultValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);
    // Here, this is the current activity
    PreferenceManager.setDefaultValues(this, R.xml.pref_settings, false);
    if (!permissionGranted()) {
        requestPermissions();
    } else {
        if (systemInstalled()) {
            startMainActivity();
        } else {
            installSystem();
        }
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:17,代码来源:SplashScreenActivity.java

示例2: onCreate

import android.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle icicle) {
	super.onCreate(icicle);

	Window window = getWindow();
	window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
	setContentView(R.layout.capture);

	hasSurface = false;
	inactivityTimer = new InactivityTimer(this);
	beepManager = new BeepManager(this);
	ambientLightManager = new AmbientLightManager(this);

	PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
	
	if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
           setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
       } else {
           setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
       }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:22,代码来源:CaptureActivity.java

示例3: onCreate

import android.preference.PreferenceManager; //导入方法依赖的package包/类
@SuppressWarnings("ConstantConditions")
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.photoviewer);
    setTheme(R.style.MakiDark);
    setContentView(R.layout.photoviewer);
    getWindow().setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle(null);
    url = getIntent().getStringExtra("url");
    if (url == null) {
        onBackPressed();
        onDestroy();
    }

    fullImage = (ImageView) findViewById(R.id.pictureholder);
    appDirectoryName = getString(R.string.app_name).replace(" ", " ");
    loadImage();
    ((SlideFinishLayout)findViewById(R.id.root_layout)).setFinishListener(new SlideFinishLayout.onSlideFinishListener() {
        @Override
        public void onSlideFinish() {
            PhotoViewer.this.finish();
            overridePendingTransition(0, 0);
        }
    });

    PreferenceManager.setDefaultValues(this, R.xml.preferences, true);
    PreferenceManager.setDefaultValues(this, R.xml.customize_preferences, true);
    preferences = PreferenceManager.getDefaultSharedPreferences(this);
    trayPreferences = new TrayAppPreferences(getApplicationContext());

    if (preferences.getBoolean("lock_portrait", false)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
    }
}
 
开发者ID:sfilmak,项目名称:MakiLite,代码行数:41,代码来源:PhotoViewer.java

示例4: onCreate

import android.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

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

    getFragmentManager().beginTransaction()
            .replace(android.R.id.content, new SettingsFragment())
            .commit();
}
 
开发者ID:xRahul,项目名称:GroupingMessages,代码行数:11,代码来源:SettingsActivity.java

示例5: onCreate

import android.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PreferenceManager.setDefaultValues(this, R.xml.notification_preferences, false);
    getFragmentManager().beginTransaction()
            .replace(android.R.id.content, new SettingsFragment())
            .commit();
}
 
开发者ID:rootkiwi,项目名称:an2linuxclient,代码行数:9,代码来源:NotificationSettingsActivity.java

示例6: onCreate

import android.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // set default values in the app's SharedPreferences if never changed
    // note - does not reset preferences back to default values if previously changed
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);

    // start location services, including permissions checks, etc.
    context = this;
    preferences = PreferenceManager.getDefaultSharedPreferences(this);
    //preferences.edit().remove("multi_pref_constellation").apply();   //used to clear existing preference if required
    useGPS = preferences.getBoolean("use_device_location", false);
    locUpdates = false;
    mFusedLocationClient = LocationServices.getFusedLocationProviderClient(context);
    mSettingsClient = LocationServices.getSettingsClient(context);
    createLocationCallback();
    createLocationRequest();
    buildLocationSettingsRequest();

    if (savedInstanceState == null) {
        // create DSObjectsFragment
        dsObjectsFragment = new DSObjectsFragment();

        // add the fragment to the FrameLayout
        FragmentTransaction transaction =
                getSupportFragmentManager().beginTransaction();
        transaction.add(R.id.fragmentContainer, dsObjectsFragment);
        transaction.commit();  // display DSObjectsFragment
    }
}
 
开发者ID:MTBehnke,项目名称:NightSkyGuide,代码行数:35,代码来源:MainActivity.java

示例7: onCreate

import android.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    overridePendingTransition(0, 0);

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

    getFragmentManager().beginTransaction()
            .replace(android.R.id.content, new GeneralPreferenceFragment())
            .commit();
}
 
开发者ID:aumarbello,项目名称:Tasks,代码行数:13,代码来源:SettingsActivity.java

示例8: onCreate

import android.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Initialize all settings with their default value as defined by the 'android:defaultValue' property
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);

    WindesheimApi api = new WindesheimApi(this);
    api.setOnScheduleSyncedListener(this);

    settings = new Settings(this);
    schedules = new SchedulesUtil(this, api);

    setContentView(R.layout.activity_main);

    Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);

    // noinspection deprecation
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    ((NavigationView) findViewById(R.id.nav_view)).setNavigationItemSelectedListener(this);

    mSwipeRefreshLayout = (CustomSwipeRefreshLayout) findViewById(R.id.refresh_layout);
    mSwipeRefreshLayout.setOnRefreshListener(this);

    String viewSetting = settings.getOption(Settings.PREF_VIEW);
    activeView = viewSetting.isEmpty() ? VIEW_DAY : Integer.parseInt(viewSetting);

    schedules.add(settings.getSchedules());
}
 
开发者ID:linklux,项目名称:android-schedules,代码行数:36,代码来源:MainActivity.java

示例9: onCreate

import android.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        parseIntentExtras();

        sessionManager = WebRtcSessionManager.getInstance(this);
        if (!currentSessionExist()) {
//            we have already currentSession == null, so it's no reason to do further initialization
            finish();
            Log.d(TAG, "finish CallActivity");
            return;
        }

        initFields();
        initCurrentSession(currentSession);

        PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
        sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
        initQBRTCClient();
        initAudioManager();
        initWiFiManagerListener();

        ringtonePlayer = new RingtonePlayer(this, R.raw.beep);
        connectionView = (LinearLayout) View.inflate(this, R.layout.connection_popup, null);
        checker = new PermissionsChecker(getApplicationContext());

        startSuitableFragment(isInCommingCall);
    }
 
开发者ID:mobilemaster128,项目名称:quickblox-android,代码行数:31,代码来源:CallActivity.java

示例10: onCreate

import android.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    helper_main.setTheme(this);

    setContentView(R.layout.activity_settings);
    helper_main.onStart(Activity_settings_app.this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    setTitle(R.string.pref_2);

    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

    android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    if(actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    PreferenceManager.setDefaultValues(this, R.xml.user_settings, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_search, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_app, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_close, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_start, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_search_main, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_data, false);
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    sharedPref.edit().putString("started", "").apply();

    // Display the fragment as the activity_screen_main content
    getFragmentManager().beginTransaction().replace(R.id.content_frame, new SettingsFragment()).commit();
}
 
开发者ID:JaeNuguid,项目名称:Kids-Portal-Android,代码行数:34,代码来源:Activity_settings_app.java

示例11: onFinishButtonPressed

import android.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
public void onFinishButtonPressed() {
    // Define your actions when the user press 'Finish' button
    PreferenceManager.setDefaultValues(this, R.xml.user_settings, false);
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    sharedPref.edit().putBoolean("introShowDo_notShow", false).apply();
    Intent intent = new Intent(this, ParentAuth.class);
    startActivity(intent);
    finish();
}
 
开发者ID:JaeNuguid,项目名称:Kids-Portal-Android,代码行数:11,代码来源:Activity_intro.java

示例12: resetPreferences

import android.preference.PreferenceManager; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void resetPreferences()
{
	this.setPreferenceScreen(null);

	SharedPreferences.Editor editor = this.preferences.edit();
	editor.clear();
	editor.commit();

	PreferenceManager.setDefaultValues(this, R.xml.settings, true);

	this.addPreferencesFromResource(R.xml.settings);
}
 
开发者ID:Elbehiry,项目名称:Pc-Control,代码行数:14,代码来源:SettingsActivity.java

示例13: onCreate

import android.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);

    // Set a Toolbar to replace the ActionBar.
    Toolbar toolbar = (Toolbar) findViewById(R.id.home_toolbar);
    setSupportActionBar(toolbar);

    LAUNCH_ACTIVITY_ANIM_BUNDLE = ActivityOptions.
            makeCustomAnimation(HomeActivity.this,
                    R.transition.left_in,
                    R.transition.left_out).toBundle();

    // Initialize settings to defaults

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle = new SmoothDrawerToggle(this, mDrawerLayout, toolbar, R.string.drawer_open,  R.string.drawer_close);

    mDrawerLayout.addDrawerListener(mDrawerToggle);

    NavigationView navDrawer = (NavigationView) findViewById(R.id.navDrawer);
    setupDrawerContent(navDrawer);


    PreferenceManager.setDefaultValues(this, R.xml.main_settings, false);
    mPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    Fragment frag = new HomeFragment();

    // Add a new fragment to the appropriate view element
    FragmentManager fragmentManager = getSupportFragmentManager();
    if (fragmentManager.findFragmentById(R.id.flContent) == null) {
        fragmentManager.beginTransaction().add(R.id.flContent, frag).commit();
    }

    if (mPreferences.getInt(getString(R.string.version_key), 0) < Constants.VERSION_CODE
            && mPreferences.getBoolean(getString(R.string.done_first_launch_key), false)) {
        // App has been updated

        if (mPreferences.getInt(getString(R.string.placeholder_dismiss_delay_key), 0) < 5) {
            // Set default Dismiss Placeholder notification delay to 7. Low delays can cause
            // problems with relaying notifications.
            mPreferences.edit()
                        .putInt(getString(R.string.placeholder_dismiss_delay_key), 7).apply();
        }

        navDrawer.setCheckedItem(R.id.nav_whats_new);
        setTitle(R.string.whats_new);
        frag = InfoFragment.newInstance(getString(R.string.whats_new_text));
        fragmentManager.beginTransaction().replace(R.id.flContent, frag).commit();

        mPreferences.edit().putInt(getString(R.string.version_key), Constants.VERSION_CODE).apply();

        // Open the database to update it in case the version is incremented.
        AppSelectionsStore store = AppSelectionsStore.get(this);
    }

    if (!mPreferences.getBoolean(getString(R.string.done_first_launch_key), false)) { // This is the first launch
        startActivityForResult(new Intent(HomeActivity.this, AppIntroActivity.class),
                APP_INTRO_FIRST_LAUNCH_INTENT,
                LAUNCH_ACTIVITY_ANIM_BUNDLE);
    }

    createNotificationChannel();
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:67,代码来源:HomeActivity.java

示例14: onCreate

import android.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_app_selector);

    LAUNCH_ACTIVITY_ANIM_BUNDLE = ActivityOptions.
            makeCustomAnimation(AppChoicesActivity.this,
                    R.transition.left_in,
                    R.transition.left_out).toBundle();

    mPackageManager = getPackageManager();
    mAppSelectionsStore = AppSelectionsStore.get(this);
    mRecyclerView = (RecyclerView) findViewById(R.id.app_selections_recycler_view);
    mLoadingView = (TextView) findViewById(R.id.app_list_loading_text_view);
    mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));

    PreferenceManager.setDefaultValues(this, R.xml.main_settings, false);
    mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mShowOnlyEnabledApps = mPreferences.getBoolean(getString(R.string.show_enabled_apps_key), false);

    if (savedInstanceState != null && getSetupStatus(savedInstanceState)) {
        mAppSelections = savedInstanceState.getParcelableArrayList(STATE_APP_SELECTIONS);
        Parcelable listState = savedInstanceState.getParcelable(STATE_RECYCLER_VIEW);

        if (mShowOnlyEnabledApps) {
            List<AppSelection> appSelectionsSubList = new ArrayList<>();

            for (AppSelection appSelection : mAppSelections) {
                if (appSelection.isSelected()) {
                    appSelectionsSubList.add(appSelection);
                }
            }
            mAdapter = new ActivityAdapter(appSelectionsSubList);
        } else {
            mAdapter = new ActivityAdapter(mAppSelections);
        }
        mRecyclerView.setAdapter(mAdapter);
        mRecyclerView.getLayoutManager().onRestoreInstanceState(listState);
        mSetupComplete = getSetupStatus(savedInstanceState);

        DebugLog log = DebugLog.get(getApplicationContext());
        if (log.isEnabled()) {
            log.writeLog("Restoring state may cause problems for some users");
            log.writeLog("Number of applications: " + mAppSelections.size());
            log.writeLog("Loading Text View text: " + mLoadingView.getText());
            log.writeLog("Loading Text View status: " + mLoadingView.getVisibility());
            log.writeLog("Setup status: " + (mSetupComplete ? "true" : "false"));
        }
    } else {
        mLoadingView.setText(getString(R.string.app_list_loading_text));
        mRecyclerView.setVisibility(View.GONE);
        mLoadingView.setVisibility(View.VISIBLE);
        mProgressBar.setVisibility(View.VISIBLE);
        new AppListSetup().execute();
    }
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:58,代码来源:AppChoicesActivity.java

示例15: onCreate

import android.preference.PreferenceManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_forge);
    // Open with keyboard hidden
    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    // Set up toolbar
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // Set up fragment pager adapter
    forgePagerAdapter = new ForgePagerAdapter(getSupportFragmentManager(), getApplicationContext());
    // Clear all scroll flags
    AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
    params.setScrollFlags(0);
    // Set up viewpager
    viewPager = findViewById(R.id.container);
    viewPager.setAdapter(forgePagerAdapter);
    // Set up tab layout
    TabLayout tabLayout = findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
    // Set up notification channel
    Notifications.setUpChannels(this);
    // Get shared preferences
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    // Get activity starting intent
    Intent intent = getIntent();
    if (intent.hasExtra(Notifications.NOTIFICATION_NAVIGATION)) {
        // If the activity was opened from a notification click
        // Set the current fragment viewed to the one requested
        viewPager.setCurrentItem(intent.getIntExtra(Notifications.NOTIFICATION_NAVIGATION, GENERATE_TAB));
    }
    // If the user preferences have not been set yet, set them to defaults
    if (!sharedPref.getBoolean(PreferenceManager.KEY_HAS_SET_DEFAULT_VALUES, false)) {
        PreferenceManager.setDefaultValues(getApplicationContext(), R.xml.pref_general, true);
        PreferenceManager.setDefaultValues(getApplicationContext(), R.xml.pref_password, true);
        PreferenceManager.setDefaultValues(getApplicationContext(), R.xml.pref_date_of_birth, true);
    }

    if (sharedPref.getBoolean(getString(R.string.pref_helper_key), false)) {
        Notifications.displayHelperNotification(this);
    } else {
        Notifications.removeHelperNotification(this);
    }

}
 
开发者ID:jthomperoo,项目名称:Forge,代码行数:46,代码来源:Forge.java


注:本文中的android.preference.PreferenceManager.setDefaultValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。