Example usage for android.os Bundle putBoolean

List of usage examples for android.os Bundle putBoolean

Introduction

In this page you can find the example usage for android.os Bundle putBoolean.

Prototype

public void putBoolean(@Nullable String key, boolean value) 

Source Link

Document

Inserts a Boolean value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:edu.ucla.cs.nopainnogame.WatchActivity.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    savedInstanceState.putBoolean("viewingBoolean", viewing);
    super.onSaveInstanceState(savedInstanceState);
    if (counter != null) {
        counter.cancel();/*w  w w  .ja v a 2 s  .c om*/
    }
}

From source file:ca.mudar.snoozy.receiver.PowerConnectionReceiver.java

@Override
public void onReceive(Context context, Intent intent) {

    final Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);

    // Get user preferences
    final SharedPreferences sharedPrefs = context.getSharedPreferences(Const.APP_PREFS_NAME,
            Context.MODE_PRIVATE);
    final SharedPreferences.Editor sharedPrefsEditor = sharedPrefs.edit();
    final boolean hasNotifications = sharedPrefs.getBoolean(Const.PrefsNames.HAS_NOTIFICATIONS, false);
    final boolean hasVibration = (sharedPrefs.getBoolean(Const.PrefsNames.HAS_VIBRATION, false)
            && vibrator.hasVibrator());
    final boolean hasSound = sharedPrefs.getBoolean(Const.PrefsNames.HAS_SOUND, false);
    final boolean onScreenLock = sharedPrefs.getBoolean(Const.PrefsNames.ON_SCREEN_LOCK, true);
    final boolean onPowerLoss = sharedPrefs.getBoolean(Const.PrefsNames.ON_POWER_LOSS, false);
    final int delayToLock = Integer.parseInt(
            sharedPrefs.getString(Const.PrefsNames.DELAY_TO_LOCK, Const.PrefsValues.DELAY_FAST)) * 1000;
    final int notifyCount = sharedPrefs.getInt(Const.PrefsNames.NOTIFY_COUNT, 1);
    final int notifyGroup = sharedPrefs.getInt(Const.PrefsNames.NOTIFY_GROUP, 1);

    final String action = intent.getAction();
    if (action == null)
        return;//from  ww  w. j av  a 2s . c  o  m

    if (action.equals(Const.IntentActions.NOTIFY_DELETE)) {
        if (hasNotifications) {
            // Reset the notification counter (and group) on NOTIFY_DELETE
            sharedPrefsEditor.putInt(Const.PrefsNames.NOTIFY_COUNT, 1);
            sharedPrefsEditor.putInt(Const.PrefsNames.NOTIFY_GROUP, notifyGroup + 1);
            sharedPrefsEditor.apply();
        }
    } else if (action.equals(Intent.ACTION_POWER_CONNECTED)
            || action.equals(Intent.ACTION_POWER_DISCONNECTED)) {
        final boolean isConnectedPower = action.equals(Intent.ACTION_POWER_CONNECTED);

        // Lock the screen, following the user preferences
        if (delayToLock == 0) {
            LockScreenHelper.lockScreen(context, onScreenLock, onPowerLoss, isConnectedPower);
        } else {
            Intent intentService = new Intent(Intent.ACTION_SYNC, null, context, DelayedLockService.class);
            Bundle extras = new Bundle();
            extras.putBoolean(Const.IntentExtras.ON_SCREEN_LOCK, onScreenLock);
            extras.putBoolean(Const.IntentExtras.ON_POWER_LOSS, onPowerLoss);
            extras.putBoolean(Const.IntentExtras.IS_CONNECTED, isConnectedPower);
            extras.putInt(Const.IntentExtras.DELAY_TO_LOCK, delayToLock);
            intentService.putExtras(extras);
            context.startService(intentService);
        }

        // Save in database
        saveHistoryItem(context.getApplicationContext(), isConnectedPower, notifyGroup);

        if (hasNotifications) {
            // Send notification, with sound and vibration
            notify(context, isConnectedPower, hasVibration, hasSound, notifyCount);

            // Increment the notification counter
            sharedPrefsEditor.putInt(Const.PrefsNames.NOTIFY_COUNT, notifyCount + 1);
            sharedPrefsEditor.apply();
        } else {
            // Native Vibration or Sound, without Notifications
            nativeVibrate(context, hasVibration);

            nativeRingtone(context, hasSound);
        }
    }
}

From source file:can.yrt.onebusaway.map.RouteMapController.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putString(MapParams.ROUTE_ID, mRouteId);
    outState.putBoolean(MapParams.ZOOM_TO_ROUTE, mZoomToRoute);
}

From source file:com.idean.atthack.api.Param.java

/**
 * Put value into bundle using the appropriate type for the value
 *///from w  w w . j a  va  2s.  c o m
public void putBundleAsTypedVal(Bundle bundle, String val) {
    if (TextUtils.isEmpty(val)) {
        return;
    }
    try {
        switch (type) {
        case BOOLEAN:
            bundle.putBoolean(name(), Boolean.parseBoolean(val));
            break;
        case FLOAT:
            bundle.putFloat(name(), Float.parseFloat(val));
            break;
        case INTEGER:
            bundle.putFloat(name(), Integer.parseInt(val));
            break;
        case STRING:
            bundle.putString(name(), val);
            break;
        default:
            throw new UnsupportedOperationException();
        }
    } catch (Exception e) {
        Log.w(TAG, "Unable to put value into bundle " + this + ", val: " + val);
    }
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_browser.SignBrowserFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    Log.d(TAG, "onSaveInstance " + hashCode());
    super.onSaveInstanceState(outState);
    outState.putBoolean(KEY_SHOW_STARRED_ONLY, this.showStarredOnly);
}

From source file:com.apptentive.android.sdk.ViewActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putBoolean("returnToPushCallbackActivity", returnToPushCallbackActivity);
    outState.putString("pushCallbackActivityName", pushCallbackActivityName);
    if (activityContent != null) {
        activityContent.onSaveInstanceState(outState);
    }/*from   ww w.j a v  a2 s .  co m*/
}

From source file:at.florian_lentsch.expirysync.AddProductActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putBoolean("scanBarcodeOnStart", false);
}

From source file:it.gulch.linuxday.android.fragments.TrackScheduleListFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putBoolean("isListAlreadyShown", isListAlreadyShown);
}

From source file:net.openid.appauth.AuthorizationManagementActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putBoolean(KEY_AUTHORIZATION_STARTED, mAuthorizationStarted);
    outState.putParcelable(KEY_AUTH_INTENT, mAuthIntent);
    outState.putString(KEY_AUTH_REQUEST, mAuthRequest.jsonSerializeString());
    outState.putParcelable(KEY_COMPLETE_INTENT, mCompleteIntent);
    outState.putParcelable(KEY_CANCEL_INTENT, mCancelIntent);
}

From source file:com.abid_mujtaba.fetchheaders.MainActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    outState.putBoolean(BUNDLE_FLAG_SHOW_SEEN, fShowSeen);
}