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:org.secuso.privacyfriendlynetmonitor.Activities.BaseActivity.java

private void callDrawerItem(final int itemId) {

    Intent intent;//from  w w  w .  jav  a2s .  c om

    switch (itemId) {
    case R.id.nav_main:
        intent = new Intent(this, MainActivity.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:at.ac.tuwien.detlef.activities.MainActivity.java

private void startSettingsActivityIfNoDeviceIdSet() {

    if (Singletons.i().getGpodderSettings().getDeviceId() != null) {
        return;/*w w w .  j a  va2 s. c om*/
    }

    final AlertDialog.Builder b = new AlertDialog.Builder(this);
    b.setTitle(R.string.detlef_says_hello);
    b.setMessage(R.string.detlef_is_not_set_up_yet);

    b.setPositiveButton(android.R.string.yes, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {

            startActivityForResult(new Intent(getApplicationContext(), SettingsActivity.class)
                    .putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsGpodderNet.class.getName())
                    .putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true)
                    .putExtra(SettingsGpodderNet.EXTRA_SETUPMODE, true), 0);

        }
    });
    b.setNegativeButton(android.R.string.no, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            Toast.makeText(getApplicationContext(), getString(R.string.you_can_setup_your_account_later),
                    Toast.LENGTH_LONG).show();

        }
    });

    b.show();

}

From source file:com.concavenp.artistrymuse.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    // The default result is that, no, we did not handle the given item
    boolean result;

    switch (item.getItemId()) {

    case R.id.action_profile: {

        // User chose to open the User Profile Editor
        onProfileInteraction();/*  www.j a v  a2 s.  com*/

        // We handled it
        result = true;

        break;

    }
    case R.id.action_settings: {

        Intent modifySettings = new Intent(MainActivity.this, SettingsActivity.class);

        // For now, give the activity some extra parameters that will tell it to use a specific
        // PreferenceFragment when starting up.  These lines can be removed when the user
        // preference settings gets more complex and require displaying preference headers to the user.
        modifySettings.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT,
                SettingsActivity.GeneralPreferenceFragment.class.getName());
        modifySettings.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true);

        startActivity(modifySettings);

        // We handled it
        result = true;

        break;

    }
    case R.id.action_logoff: {

        // The user chose to log out
        AuthUI.getInstance().signOut(this);

        // We handled it
        result = true;

        break;

    }
    default: {

        // If we got here, the user's action was not recognized.
        // Invoke the superclass to handle it.
        result = super.onOptionsItemSelected(item);

        break;

    }

    }

    return result;

}

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

/**
 * Handles a new intent, either from onNewIntent() or onCreate()
 * @param intent The intent to handle/*ww w.j a v a 2 s  . c om*/
 * @return Whether we should attempt to restore the saved timer state. Will be false when
 *  this method opens another Activity.
 */
private boolean handleIntent(Intent intent) {
    boolean shouldRestoreSavedTimer = true;

    if (intent.getBooleanExtra(EXTRA_SNOOZE, false)) {
        // The activity was launched from the expanded notification's "Snooze" action

        snoozeTimer();
        // In case user didn't interact with the RingingActivity, and instead snoozed directly
        //  from the notification
        AlarmRinger.stop(this);

        // Don't restore, since we're about to open a new Activity
        shouldRestoreSavedTimer = false;

    } else if (intent.getBooleanExtra(EXTRA_ALARM_RING, false)) {
        // The Activity was launched from AlarmReceiver, meaning the timer finished and we
        //  need to ring the alarm

        Intent ringingIntent = new Intent(this, RingingActivity.class);
        // Pass along FLAG_ACTIVITY_NO_USER_ACTION if it was set when calling this activity
        if ((intent.getFlags() & Intent.FLAG_ACTIVITY_NO_USER_ACTION) != 0)
            ringingIntent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
        startActivityForResult(ringingIntent, RingingActivity.REQUEST_ALARM_RING);

        // Don't restore, since we're about to open a new Activity
        shouldRestoreSavedTimer = false;

    } else if (intent.getBooleanExtra(EXTRA_SCHEDULED_START, false)) {
        // The Activity was launched from ScheduledStartReceiver, meaning it's time for the
        //  scheduled start

        // Show a dialog prompting the user to start
        new AlertDialog.Builder(this).setTitle(R.string.scheduled_dialog_title)
                .setMessage(R.string.scheduled_dialog_message)
                .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        // Start the timer
                        circleTimer.performClick();
                    }
                }).setNeutralButton(R.string.action_settings, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        // Show the settings activity with the Scheduled Start settings
                        Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
                        intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT,
                                ScheduledStartSettingsFragment.class.getName());
                        intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_TITLE,
                                R.string.pref_category_scheduled);
                        startActivity(intent);
                    }
                }).setNegativeButton(R.string.cancel, null).show();
    }

    return shouldRestoreSavedTimer;
}

From source file:com.android.stockbrowser.WebStorageSizeManager.java

private void scheduleOutOfSpaceNotification() {
    if (LOGV_ENABLED) {
        Log.v(LOGTAG, "scheduleOutOfSpaceNotification called.");
    }//from   w  ww  .java  2 s .c om
    if ((mLastOutOfSpaceNotificationTime == -1)
            || (System.currentTimeMillis() - mLastOutOfSpaceNotificationTime > NOTIFICATION_INTERVAL)) {
        // setup the notification boilerplate.
        int icon = android.R.drawable.stat_sys_warning;
        CharSequence title = mContext.getString(R.string.webstorage_outofspace_notification_title);
        CharSequence text = mContext.getString(R.string.webstorage_outofspace_notification_text);
        long when = System.currentTimeMillis();
        Intent intent = new Intent(mContext, BrowserPreferencesPage.class);
        intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, WebsiteSettingsFragment.class.getName());
        PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0, intent, 0);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext).setContentTitle(title)
                .setContentIntent(contentIntent).setContentText(text).setSmallIcon(icon).setAutoCancel(true);

        NotificationManager mgr = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
        if (mgr != null) {
            mLastOutOfSpaceNotificationTime = System.currentTimeMillis();
            mgr.notify(OUT_OF_SPACE_ID, builder.build());
        }
    }
}

From source file:com.sabaibrowser.WebStorageSizeManager.java

private void scheduleOutOfSpaceNotification() {
    if (LOGV_ENABLED) {
        Log.v(LOGTAG, "scheduleOutOfSpaceNotification called.");
    }/*from  w w  w. j a va2s.co m*/
    if ((mLastOutOfSpaceNotificationTime == -1)
            || (System.currentTimeMillis() - mLastOutOfSpaceNotificationTime > NOTIFICATION_INTERVAL)) {
        // setup the notification boilerplate.
        int icon = android.R.drawable.stat_sys_warning;
        CharSequence title = mContext.getString(R.string.webstorage_outofspace_notification_title);
        CharSequence text = mContext.getString(R.string.webstorage_outofspace_notification_text);
        long when = System.currentTimeMillis();
        Intent intent = new Intent(mContext, BrowserSettingsActivity.class);
        intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, WebsiteSettingsFragment.class.getName());
        PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0, intent, 0);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext);
        Notification notification = builder.setContentIntent(contentIntent).setSmallIcon(icon).setTicker(text)
                .setWhen(when).setAutoCancel(true).setContentTitle(title).setContentText(text).build();

        // Fire away.
        String ns = Context.NOTIFICATION_SERVICE;
        NotificationManager mgr = (NotificationManager) mContext.getSystemService(ns);
        if (mgr != null) {
            mLastOutOfSpaceNotificationTime = System.currentTimeMillis();
            mgr.notify(OUT_OF_SPACE_ID, notification);
        }
    }
}

From source file:g7.bluesky.launcher3.Launcher.java

protected void showSettings() {
    final Intent settingsActivity = new Intent(this, SettingsActivity.class);
    // Use only one setting fragment
    settingsActivity.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT,
            SettingsActivity.GeneralPreferenceFragment.class.getName());
    settingsActivity.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true);
    startActivity(settingsActivity);/*from w ww .  j a v a2  s  . c o  m*/
}