Example usage for android.os Bundle getBoolean

List of usage examples for android.os Bundle getBoolean

Introduction

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

Prototype

public boolean getBoolean(String key) 

Source Link

Document

Returns the value associated with the given key, or false if no mapping of the desired type exists for the given key.

Usage

From source file:org.elasticdroid.SshConnectorView.java

/**
 * Restore instance state when the activity is reconstructed after a destroy
 * /*  w w w  . ja  v a 2 s .  c o  m*/
 * This method restores:
 * <ul>
 * <li></li>
 * </ul>
 */
@SuppressWarnings("unchecked")
@Override
public void onRestoreInstanceState(Bundle stateToRestore) {
    //restore alertDialogDisplayed boolean
    alertDialogDisplayed = stateToRestore.getBoolean("alertDialogDisplayed");
    Log.v(this.getClass().getName(), "alertDialogDisplayed = " + alertDialogDisplayed);
    alertDialogMessage = stateToRestore.getString("alertDialogMessage");

    //was a progress dialog being displayed? Restore the answer to this question.
    progressDialogDisplayed = stateToRestore.getBoolean("progressDialogDisplayed");
    Log.v(this.getClass().getName() + ".onRestoreInstanceState",
            "progressDialogDisplayed:" + progressDialogDisplayed);

    /*get the model data back, so that you can inform the model that the activity
     * has come back up. */
    Object retained = getLastNonConfigurationInstance();
    //if there was a model executing when the object was destroyed, retained will be an 
    //instance of SecurityGroupsModel
    if (retained instanceof SecurityGroupsModel) {
        Log.i(TAG + ".onRestoreInstanceState()", "Reclaiming previous " + "background task");
        securityGroupsModel = (SecurityGroupsModel) retained;
        securityGroupsModel.setActivity(this);//tell the model of the new activity created
    } else {
        securityGroupsModel = null;

        Log.v(TAG, "No model object, or model finished before activity " + "was recreated.");

        //now if there is no model anymore, and progressDialogDisplayed is set to true,
        //reset it to false, because the model finished executing before the restart
        if (progressDialogDisplayed) {
            progressDialogDisplayed = false;
        }
    }

    Log.d(TAG, "Restoring open ports data if any");

    try {
        openPorts = (ArrayList<String>) stateToRestore.getSerializable("openPorts");
    } catch (Exception exception) {
        openPorts = null;
    }

    //if we have openPorts data, populate the spinner
    if (openPorts != null) {
        populateSpinner();
        //populate spinner will have set the spinner to port 22
        //or to the first index
        //reposition the selected index
        ((Spinner) findViewById(R.id.sshConnectorPortSpinner))
                .setSelection(stateToRestore.getInt("selectedPortPos"));
    }

    //if the user has entered new username, set that into EditText
    if (stateToRestore.getString("sshUsername") != null) {
        ((EditText) findViewById(R.id.sshConnectorUsernameEditTextView))
                .setText(stateToRestore.getString("sshUsername"));
    }

    //set the pubkey auth checkbox
    ((CheckBox) findViewById(R.id.sshConnectorUsePublicKeyAuth))
            .setChecked(stateToRestore.getBoolean("usePubkeyAuth"));
}

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

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

    Bundle bundle = FragmentFactory.addDisplayModeToFragmentBundle(getIntent().getExtras());
    boolean isInteractionModal = bundle.getBoolean(Constants.FragmentConfigKeys.MODAL);

    ApptentiveBaseFragment newFragment = null;
    if (savedInstanceState != null) {
        // retrieve the retained fragment after orientation change using saved tag
        String savedFragmentTag = savedInstanceState.getString(FRAGMENT_TAG);
        newFragment = (ApptentiveBaseFragment) getSupportFragmentManager().findFragmentByTag(savedFragmentTag);
        /* Since we always store tags of fragments in the ViewPager upon orientation change,
         * failure of retrieval indicate internal error
         *///w  w  w  .  j a v  a  2 s  .  c  o  m
        if (newFragment == null) {
            finish();
            return;
        }
    }
    try {
        fragmentType = bundle.getInt(Constants.FragmentConfigKeys.TYPE, Constants.FragmentTypes.UNKNOWN);

        if (fragmentType != Constants.FragmentTypes.UNKNOWN) {
            if (fragmentType == Constants.FragmentTypes.INTERACTION
                    || fragmentType == Constants.FragmentTypes.MESSAGE_CENTER_ERROR
                    || fragmentType == Constants.FragmentTypes.ABOUT) {
                bundle.putInt("toolbarLayoutId", R.id.apptentive_toolbar);
                if (newFragment == null) {
                    newFragment = FragmentFactory.createFragmentInstance(bundle);
                    isInteractionModal = newFragment.isShownAsModalDialog();
                }
                if (newFragment != null) {
                    applyApptentiveTheme(isInteractionModal);
                    newFragment.setOnTransitionListener(this);
                }
            }

            if (newFragment == null) {
                if (fragmentType == Constants.FragmentTypes.ENGAGE_INTERNAL_EVENT) {
                    String eventName = getIntent().getStringExtra(Constants.FragmentConfigKeys.EXTRA);
                    if (eventName != null) {
                        EngagementModule.engageInternal(this, eventName);
                    }
                }
                finish();
                return;
            }

        }
    } catch (Exception e) {
        ApptentiveLog.e("Error creating ApptentiveViewActivity.", e);
        MetricModule.sendError(e, null, null);
    }

    setContentView(R.layout.apptentive_viewactivity);

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

    /* Add top padding by the amount of Status Bar height to avoid toolbar being covered when
     * status bar is translucent
     */
    toolbar.setPadding(0, getToolbarHeightAdjustment(!isInteractionModal), 0, 0);

    ActionBar actionBar = getSupportActionBar();

    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        int navIconResId = newFragment.getToolbarNavigationIconResourceId(getTheme());
        // Check if fragment may show an alternative navigation icon
        if (navIconResId != 0) {
            /* In order for the alternative icon has the same color used by toolbar icon,
             * need to apply the same color in toolbar theme
             * By default colorControlNormal has same value as textColorPrimary defined in toolbar theme overlay
             */
            final Drawable alternateUpArrow = ResourcesCompat.getDrawable(getResources(), navIconResId,
                    getTheme());

            int colorControlNormal = Util.getThemeColor(
                    ApptentiveInternal.getInstance().getApptentiveToolbarTheme(), R.attr.colorControlNormal);
            alternateUpArrow.setColorFilter(colorControlNormal, PorterDuff.Mode.SRC_ATOP);
            actionBar.setHomeAsUpIndicator(alternateUpArrow);
        }
    }

    //current_tab = extra.getInt(SELECTED_TAB_EXTRA_KEY, 0);
    current_tab = 0;

    addFragmentToAdapter(newFragment, newFragment.getTitle());

    // Get the ViewPager and set it's PagerAdapter so that it can display items
    viewPager = (ViewPager) findViewById(R.id.apptentive_vp);
    viewPager.setAdapter(viewPager_Adapter);

    ViewPager.OnPageChangeListener pageChangeListener = new ViewPager.OnPageChangeListener() {
        Boolean first = true;

        @Override
        public void onPageSelected(int position) {
            final ApptentiveBaseFragment currentFragment = (ApptentiveBaseFragment) viewPager_Adapter
                    .getItem(viewPager.getCurrentItem());
            // Set the Activity title for TalkBack support
            final String title = currentFragment.getTitle();
            if (currentFragment != null && currentFragment.getActivity() != null) {
                currentFragment.getActivity().setTitle(title);
            }
            if (!currentFragment.isShownAsModalDialog()) {
                toolbar.post(new Runnable() {
                    @Override
                    public void run() {
                        toolbar.setVisibility(View.VISIBLE);
                        toolbar.setTitle(title);
                    }
                });
            } else {
                toolbar.setVisibility(View.GONE);
            }
            current_tab = position;
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            if (first && positionOffset == 0 && positionOffsetPixels == 0) {
                onPageSelected(current_tab);
                first = false;
            }
        }

        @Override
        public void onPageScrollStateChanged(int pos) {
            // TODO Auto-generated method stub
        }
    };

    viewPager.addOnPageChangeListener(pageChangeListener);

    // Needed to prevent the window from being panned up when the keyboard is opened.
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}

From source file:com.android.deskclock.RingtonePickerDialogFragment.java

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

    // Restore saved instance state.
    if (savedInstanceState != null) {
        mRequestingPermission = savedInstanceState.getBoolean(STATE_KEY_REQUESTING_PERMISSION);
        mSelectedRingtoneUri = savedInstanceState.getParcelable(STATE_KEY_SELECTED_RINGTONE_URI);
    } else {/*from   ww  w. j a  va  2 s.com*/
        // Initialize selection to the existing ringtone.
        mSelectedRingtoneUri = getArguments().getParcelable(ARGS_KEY_EXISTING_RINGTONE_URI);
    }
}

From source file:com.amansoni.tripbook.activity.LocationLookup.java

/**
 * Updates fields based on data stored in the bundle.
 *///from  ww w.j a  va2  s .  c o m
private void updateValuesFromBundle(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        // Check savedInstanceState to see if the address was previously requested.
        if (savedInstanceState.keySet().contains(ADDRESS_REQUESTED_KEY)) {
            mAddressRequested = savedInstanceState.getBoolean(ADDRESS_REQUESTED_KEY);
        }

        if (savedInstanceState.keySet().contains(IMAGE_URI)) {
            //                mImageFilePath = savedInstanceState.getString(IMAGE_URI);
            showImage();
        }
        // Check savedInstanceState to see if the location address string was previously found
        // and stored in the Bundle. If it was found, display the address string in the UI.
        if (savedInstanceState.keySet().contains(LOCATION_ADDRESS_KEY)) {
            mAddressOutput = savedInstanceState.getString(LOCATION_ADDRESS_KEY);
            displayAddressOutput();
        }
    }
}

From source file:com.adevani.mytube.MainActivity.java

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

    // Restore from saved instance state
    // [START restore_saved_instance_state]
    if (savedInstanceState != null) {
        mIsResolving = savedInstanceState.getBoolean(KEY_IS_RESOLVING);
        mShouldResolve = savedInstanceState.getBoolean(KEY_SHOULD_RESOLVE);
    }//from   w  ww.  j a va  2 s  .co m
    // [END restore_saved_instance_state]

    // Set up button click listeners
    findViewById(R.id.sign_in_button).setOnClickListener(this);
    findViewById(R.id.sign_out_button).setOnClickListener(this);
    findViewById(R.id.disconnect_button).setOnClickListener(this);

    // Large sign-in
    ((SignInButton) findViewById(R.id.sign_in_button)).setSize(SignInButton.SIZE_WIDE);

    // Start with sign-in button disabled until sign-in either succeeds or fails
    findViewById(R.id.sign_in_button).setEnabled(false);

    // Set up view instances
    mStatus = (TextView) findViewById(R.id.status);

    // [START create_google_api_client]
    // Build GoogleApiClient with access to basic profile
    mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this).addApi(Plus.API).addScope(new Scope(Scopes.PROFILE))
            .addScope(new Scope(Scopes.EMAIL)).addScope(new Scope(YouTubeScopes.YOUTUBE)).build();
    // [END create_google_api_client]
}

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

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

    day = (Day) getArguments().getSerializable(ARG_DAY);
    handler = new Handler(this);

    events = new ArrayList<>();

    adapter = new TrackScheduleAdapter(getActivity(), events);
    setListAdapter(adapter);//from   w ww  .j  a  v a  2 s  .  c  o m

    if (savedInstanceState != null) {
        isListAlreadyShown = savedInstanceState.getBoolean("isListAlreadyShown");
    }
}

From source file:ca.ualberta.app.activity.CreateAnswerActivity.java

@Override
public void onStart() {
    super.onStart();
    Intent intent = getIntent();//from  w  w w . j ava 2s.c  o m
    if (intent != null) {
        Bundle extras = intent.getExtras();
        if (extras != null) {
            if (extras.getBoolean(EDIT_MODE)) {
                String answerContent = extras.getString(ANSWER_CONTENT);
                contentText.setText(answerContent);
                try {
                    byte[] imageByteArray = Base64.decode(extras.getByteArray(IMAGE), Base64.NO_WRAP);
                    image = BitmapFactory.decodeByteArray(imageByteArray, 0, imageByteArray.length);
                    scaleImage(THUMBIMAGESIZE, THUMBIMAGESIZE, true);
                    imageView.setVisibility(View.VISIBLE);
                    imageView.setImageBitmap(imageThumb);
                } catch (Exception e) {
                }

            }
        }
    }
}

From source file:com.android.server.telecom.testapps.TestConnectionService.java

@Override
public Connection onCreateIncomingConnection(PhoneAccountHandle connectionManagerAccount,
        final ConnectionRequest request) {
    PhoneAccountHandle accountHandle = request.getAccountHandle();
    ComponentName componentName = new ComponentName(this, TestConnectionService.class);

    if (accountHandle != null && componentName.equals(accountHandle.getComponentName())) {
        final TestConnection connection = new TestConnection(true);
        // Get the stashed intent extra that determines if this is a video call or audio call.
        Bundle extras = request.getExtras();
        boolean isVideoCall = extras.getBoolean(EXTRA_IS_VIDEO_CALL);
        Uri providedHandle = extras.getParcelable(EXTRA_HANDLE);

        // Use dummy number for testing incoming calls.
        Uri address = providedHandle == null
                ? Uri.fromParts(PhoneAccount.SCHEME_TEL, getDummyNumber(isVideoCall), null)
                : providedHandle;/*w w  w.  ja v a2  s.c om*/

        int videoState = isVideoCall ? VideoProfile.STATE_BIDIRECTIONAL : VideoProfile.STATE_AUDIO_ONLY;
        connection.setVideoState(videoState);
        setAddress(connection, address);

        addVideoProvider(connection);

        addCall(connection);

        ConnectionRequest newRequest = new ConnectionRequest(request.getAccountHandle(), address,
                request.getExtras(), videoState);
        connection.setVideoState(videoState);
        return connection;
    } else {
        return Connection.createFailedConnection(new DisconnectCause(DisconnectCause.ERROR,
                "Invalid inputs: " + accountHandle + " " + componentName));
    }
}

From source file:com.bakhtiyor.android.tumblr.TumblrService.java

@Override
public void onStart(Intent intent, int startId) {
    super.onStart(intent, startId);
    Bundle extras = intent.getExtras();
    if (Intent.ACTION_SEND.equals(intent.getAction()) && (extras != null)) {
        if (extras.containsKey(KEY_EMAIL) && extras.containsKey(KEY_PASSWORD) && extras.containsKey(KEY_CAPTION)
                && extras.containsKey(KEY_IS_PRIVATE) && extras.containsKey(KEY_FILENAME)) {
            String email = extras.getString(KEY_EMAIL);
            String password = extras.getString(KEY_PASSWORD);
            String caption = extras.getString(KEY_CAPTION);
            boolean isPrivate = extras.getBoolean(KEY_IS_PRIVATE);
            String filename = extras.getString(KEY_FILENAME);
            uploadPhoto(email, password, caption, isPrivate, filename);
        }//w ww .  j a  v  a 2 s .  c  o  m
    }
    stopSelf(startId);
}