Example usage for android.preference PreferenceActivity EXTRA_SHOW_FRAGMENT

List of usage examples for android.preference PreferenceActivity EXTRA_SHOW_FRAGMENT

Introduction

In this page you can find the example usage for android.preference PreferenceActivity EXTRA_SHOW_FRAGMENT.

Prototype

String EXTRA_SHOW_FRAGMENT

To view the source code for android.preference PreferenceActivity EXTRA_SHOW_FRAGMENT.

Click Source Link

Document

When starting this activity, the invoking Intent can contain this extra string to specify which fragment should be initially displayed.

Usage

From source file:edgargtzg.popularmovies.MovieDetailsActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.action_settings) {
        Intent intent = new Intent(this, SettingsActivity.class);
        intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT,
                SettingsActivity.PrefsDiscoverMovies.class.getName());
        intent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true);
        startActivity(intent);//from w w w . j  a  v  a  2 s.c  o  m
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:ca.mudar.snoozy.ui.activity.SettingsActivity.java

@Override
public Intent getIntent() {
    // Override the original intent to remove headers and directly show SettingsFragment
    final Intent intent = new Intent(super.getIntent());
    intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsFragment.class.getName());
    intent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true);
    return intent;
}

From source file:com.xargsgrep.portknocker.activity.HostListActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case MENU_ITEM_ID_ADD:
        Intent editHostIntent = new Intent(this, EditHostActivity.class);
        startActivity(editHostIntent);/*from w  ww . j a v a  2s  .  c  o  m*/
        return true;
    case MENU_ITEM_ID_SETTINGS:
        Intent settingsIntent = null;
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
            // PreferenceFragment is not part of the compatibility package
            settingsIntent = new Intent(this, SettingsActivityCompat.class);
        } else {
            settingsIntent = new Intent(this, SettingsActivity.class);
            settingsIntent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true);
            settingsIntent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT,
                    PreferencesFragment.class.getName());
        }
        startActivity(settingsIntent);
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:org.sufficientlysecure.keychain.ui.ImportKeysCloudFragment.java

/**
 * Inflate the layout for this fragment//from w ww.  j  ava  2  s.  c o m
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.import_keys_cloud_fragment, container, false);

    mQueryEditText = (AutoCompleteTextView) view.findViewById(R.id.cloud_import_server_query);

    ContactHelper contactHelper = new ContactHelper(getActivity());
    List<String> namesAndEmails = contactHelper.getContactNames();
    namesAndEmails.addAll(contactHelper.getContactMails());
    mQueryEditText.setThreshold(3);
    mQueryEditText.setAdapter(
            new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item, namesAndEmails));

    View searchButton = view.findViewById(R.id.cloud_import_server_search);
    searchButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            search(mQueryEditText.getText().toString());
        }
    });

    mQueryEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                search(mQueryEditText.getText().toString());

                // Don't return true to let the keyboard close itself after pressing search
                return false;
            }
            return false;
        }
    });

    View configButton = view.findViewById(R.id.cloud_import_server_config_button);
    configButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(mImportActivity, SettingsActivity.class);
            intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT,
                    SettingsActivity.CloudSearchPrefsFragment.class.getName());
            startActivity(intent);
        }
    });

    return view;
}

From source file:com.xengar.android.stocktracker.ui.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    switch (id) {
    case R.id.action_settings:
        Intent intent = new Intent(this, SettingsActivity.class);
        intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT,
                SettingsActivity.GeneralPreferenceFragment.class.getName());
        intent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true);
        intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_TITLE, R.string.action_settings);
        startActivity(intent);//w  w  w  . j  ava2s  . c  o  m
        return true;

    case R.id.action_add:
        new AddStockDialog().show(getFragmentManager(), getString(R.string.dialog_class_name));
        break;
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.miz.mizuu.Main.java

@Override
public void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.Mizuu_Theme_Overview);

    super.onCreate(savedInstanceState);

    mPicasso = MizuuApplication.getPicasso(getApplicationContext());

    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
    mStartup = Integer.valueOf(settings.getString(STARTUP_SELECTION, "1"));

    mDbHelper = MizuuApplication.getMovieAdapter();
    mDbHelperTv = MizuuApplication.getTvDbAdapter();

    mTfMedium = TypefaceUtils.getRobotoMedium(getApplicationContext());
    mTfRegular = TypefaceUtils.getRoboto(getApplicationContext());

    setupMenuItems();// w  w  w.  j a v  a2s  .  co  m

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.color_primary_dark));
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_list_shadow, GravityCompat.START);

    mDrawerList = (ListView) findViewById(R.id.listView1);
    mDrawerList.setLayoutParams(new FrameLayout.LayoutParams(ViewUtils.getNavigationDrawerWidth(this),
            FrameLayout.LayoutParams.MATCH_PARENT));
    mDrawerList.setAdapter(new MenuAdapter());
    mDrawerList.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            switch (mMenuItems.get(arg2).getType()) {
            case MenuItem.HEADER:

                Intent intent = new Intent(getApplicationContext(), Preferences.class);
                intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, AccountsFragment.class.getName());
                intent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true);
                intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_TITLE, getString(R.string.social));
                intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_SHORT_TITLE, getString(R.string.social));

                startActivity(intent);
                break;

            case MenuItem.SECTION:
                loadFragment(mMenuItems.get(arg2).getFragment());
                break;
            case MenuItem.SETTINGS_AREA:

                Intent smallIntent = new Intent(getApplicationContext(), Preferences.class);
                startActivity(smallIntent);

                mDrawerLayout.closeDrawers();

                break;
            }
        }
    });

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close);
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    if (savedInstanceState != null && savedInstanceState.containsKey("selectedIndex")) {
        selectedIndex = savedInstanceState.getInt("selectedIndex");
        loadFragment(selectedIndex);
    } else if (getIntent().getExtras() != null && getIntent().getExtras().containsKey("startup")) {
        loadFragment(Integer.parseInt(getIntent().getExtras().getString("startup")));
    } else {
        loadFragment(mStartup);
    }

    LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver,
            new IntentFilter(LocalBroadcastUtils.UPDATE_MOVIE_LIBRARY));
    LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver,
            new IntentFilter(LocalBroadcastUtils.UPDATE_TV_SHOW_LIBRARY));
}

From source file:com.android.settings.locationprivacy.LocationPrivacyAdvancedSettings.java

private void addNotification(int id, int textID) {
    String text = getResources().getString(textID);
    Intent intent = new Intent(getActivity(), getActivity().getClass());
    intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, LocationPrivacySettings.class.getName());
    intent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pIntent = PendingIntent.getActivity(getActivity(), 0, intent, 0);

    Notification noti = new Notification.Builder(getActivity())
            .setContentTitle(getResources().getString(R.string.lp_webservice_notification_title))
            .setSmallIcon(R.drawable.ic_settings_locationprivacy)
            .setStyle(new Notification.BigTextStyle().bigText(text)).setContentIntent(pIntent)
            .setAutoCancel(true).build();

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            getActivity().NOTIFICATION_SERVICE);
    notificationManager.cancel(WEBSERVICE_ERROR);
    notificationManager.cancel(WEBSERVICE_OK);
    notificationManager.cancel(GOOGLE_PLAY);
    notificationManager.notify(id, noti);
}

From source file:net.sf.aria2.Aria2Service.java

private Notification createNf() {
    @SuppressLint("InlinedApi")
    final Intent targetIntent = new Intent(getApplicationContext(), MainActivity.class)
            .putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, "net.sf.aria2.MainActivity$Aria2Preferences");

    final PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, targetIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    return new NotificationCompat.Builder(getApplicationContext()).setSmallIcon(R.drawable.ic_nf_icon)
            .setTicker("Aria2 is running").setContentTitle("Aria2 is running")
            .setContentText("Touch to open settings").setContentIntent(contentIntent).setOnlyAlertOnce(true)
            .build();//from  w  w w  . ja v a  2 s .c o m
}

From source file:org.secuso.privacyfriendlypasswordgenerator.activities.BaseActivity.java

private void callDrawerItem(final int itemId) {

    Intent intent;//from ww w . j  a va2  s .com

    switch (itemId) {
    case R.id.nav_example:
        intent = new Intent(this, MainActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        break;
    case R.id.nav_tutorial:
        PrefManager prefManager = new PrefManager(this);
        prefManager.setTutorialLaunch(true);
        intent = new Intent(this, TutorialActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        break;
    case R.id.nav_about:
        intent = new Intent(this, AboutActivity.class);
        createBackStack(intent);
        break;
    case R.id.nav_help:
        intent = new Intent(this, HelpActivity.class);
        createBackStack(intent);
        break;
    case R.id.nav_settings:
        intent = new Intent(this, SettingsActivity.class);
        intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT,
                SettingsActivity.GeneralPreferenceFragment.class.getName());
        intent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true);
        createBackStack(intent);
        break;
    default:
    }
}

From source file:org.sufficientlysecure.keychain.ui.ImportKeysSearchFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int itemId = item.getItemId();
    switch (itemId) {
    case R.id.menu_import_keys_cloud_settings:
        Intent intent = new Intent(mActivity, SettingsActivity.class);
        intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT,
                SettingsActivity.CloudSearchPrefsFragment.class.getName());
        startActivity(intent);/*w  ww  .j  a va2 s  .  c  om*/
        return true;
    }

    return super.onOptionsItemSelected(item);
}