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:com.andryr.musicplayer.fragments.PlaylistFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle args = getArguments();
    setHasOptionsMenu(true);//from  w w w  .  j av a  2 s  .co  m
    if (args != null) {

        if (args.getBoolean(PARAM_PLAYLIST_FAVORITES)) {
            mFavorites = true;
        } else {
            long id = args.getLong(PARAM_PLAYLIST_ID);
            String name = args.getString(PARAM_PLAYLIST_NAME);
            mPlaylist = new Playlist(id, name);
        }
    }
}

From source file:android.support.v17.leanback.app.BrandedSupportFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    if (savedInstanceState != null) {
        mShowingTitle = savedInstanceState.getBoolean(TITLE_SHOW);
    }/*from w  ww  .  ja  va  2 s.  c  o m*/
    if (mTitleView != null && view instanceof ViewGroup) {
        mTitleHelper = new TitleHelper((ViewGroup) view, mTitleView);
    }
}

From source file:com.abhijitvalluri.android.fitnotifications.AppChoicesActivity.java

private boolean getSetupStatus(Bundle state) {
    return state.getBoolean(STATE_SETUP_COMPLETE);
}

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

private static void init(Activity activity) {

    ////from   w  ww . j ava 2 s  . c  om
    // First, initialize data relies on synchronous reads from local resources.
    //

    final Context appContext = activity.getApplicationContext();

    if (!GlobalInfo.initialized) {
        SharedPreferences prefs = appContext.getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE);

        // First, Get the api key, and figure out if app is debuggable.
        GlobalInfo.isAppDebuggable = false;
        String apiKey = null;
        boolean apptentiveDebug = false;
        String logLevelOverride = null;
        try {
            ApplicationInfo ai = appContext.getPackageManager().getApplicationInfo(appContext.getPackageName(),
                    PackageManager.GET_META_DATA);
            Bundle metaData = ai.metaData;
            if (metaData != null) {
                apiKey = metaData.getString(Constants.MANIFEST_KEY_APPTENTIVE_API_KEY);
                logLevelOverride = metaData.getString(Constants.MANIFEST_KEY_APPTENTIVE_LOG_LEVEL);
                apptentiveDebug = metaData.getBoolean(Constants.MANIFEST_KEY_APPTENTIVE_DEBUG);
                ApptentiveClient.useStagingServer = metaData
                        .getBoolean(Constants.MANIFEST_KEY_USE_STAGING_SERVER);
            }
            if (apptentiveDebug) {
                Log.i("Apptentive debug logging set to VERBOSE.");
                ApptentiveInternal.setMinimumLogLevel(Log.Level.VERBOSE);
            } else if (logLevelOverride != null) {
                Log.i("Overriding log level: %s", logLevelOverride);
                ApptentiveInternal.setMinimumLogLevel(Log.Level.parse(logLevelOverride));
            } else {
                GlobalInfo.isAppDebuggable = (ai.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
                if (GlobalInfo.isAppDebuggable) {
                    ApptentiveInternal.setMinimumLogLevel(Log.Level.VERBOSE);
                }
            }
        } catch (Exception e) {
            Log.e("Unexpected error while reading application info.", e);
        }

        Log.i("Debug mode enabled? %b", GlobalInfo.isAppDebuggable);

        // If we are in debug mode, but no api key is found, throw an exception. Otherwise, just assert log. We don't want to crash a production app.
        String errorString = "No Apptentive api key specified. Please make sure you have specified your api key in your AndroidManifest.xml";
        if ((Util.isEmpty(apiKey))) {
            if (GlobalInfo.isAppDebuggable) {
                AlertDialog alertDialog = new AlertDialog.Builder(activity).setTitle("Error")
                        .setMessage(errorString).setPositiveButton("OK", null).create();
                alertDialog.setCanceledOnTouchOutside(false);
                alertDialog.show();
            }
            Log.e(errorString);
        }
        GlobalInfo.apiKey = apiKey;

        Log.i("API Key: %s", GlobalInfo.apiKey);

        // Grab app info we need to access later on.
        GlobalInfo.appPackage = appContext.getPackageName();
        GlobalInfo.androidId = Settings.Secure.getString(appContext.getContentResolver(),
                android.provider.Settings.Secure.ANDROID_ID);

        // Check the host app version, and notify modules if it's changed.
        try {
            PackageManager packageManager = appContext.getPackageManager();
            PackageInfo packageInfo = packageManager.getPackageInfo(appContext.getPackageName(), 0);

            Integer currentVersionCode = packageInfo.versionCode;
            String currentVersionName = packageInfo.versionName;
            VersionHistoryStore.VersionHistoryEntry lastVersionEntrySeen = VersionHistoryStore
                    .getLastVersionSeen(appContext);
            if (lastVersionEntrySeen == null) {
                onVersionChanged(appContext, null, currentVersionCode, null, currentVersionName);
            } else {
                if (!currentVersionCode.equals(lastVersionEntrySeen.versionCode)
                        || !currentVersionName.equals(lastVersionEntrySeen.versionName)) {
                    onVersionChanged(appContext, lastVersionEntrySeen.versionCode, currentVersionCode,
                            lastVersionEntrySeen.versionName, currentVersionName);
                }
            }

            GlobalInfo.appDisplayName = packageManager
                    .getApplicationLabel(packageManager.getApplicationInfo(packageInfo.packageName, 0))
                    .toString();
        } catch (PackageManager.NameNotFoundException e) {
            // Nothing we can do then.
            GlobalInfo.appDisplayName = "this app";
        }

        // Grab the conversation token from shared preferences.
        if (prefs.contains(Constants.PREF_KEY_CONVERSATION_TOKEN)
                && prefs.contains(Constants.PREF_KEY_PERSON_ID)) {
            GlobalInfo.conversationToken = prefs.getString(Constants.PREF_KEY_CONVERSATION_TOKEN, null);
            GlobalInfo.personId = prefs.getString(Constants.PREF_KEY_PERSON_ID, null);
        }

        GlobalInfo.initialized = true;
        Log.v("Done initializing...");
    } else {
        Log.v("Already initialized...");
    }

    // Initialize the Conversation Token, or fetch if needed. Fetch config it the token is available.
    if (GlobalInfo.conversationToken == null || GlobalInfo.personId == null) {
        asyncFetchConversationToken(appContext.getApplicationContext());
    } else {
        asyncFetchAppConfiguration(appContext.getApplicationContext());
        InteractionManager.asyncFetchAndStoreInteractions(appContext.getApplicationContext());
    }

    // TODO: Do this on a dedicated thread if it takes too long. Some devices are slow to read device data.
    syncDevice(appContext);
    syncSdk(appContext);
    syncPerson(appContext);

    Log.d("Default Locale: %s", Locale.getDefault().toString());
    SharedPreferences prefs = appContext.getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE);
    Log.d("Conversation id: %s", prefs.getString(Constants.PREF_KEY_CONVERSATION_ID, "null"));
}

From source file:edu.rit.csh.androidwebnews.PostSwipeableActivity.java

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

    ViewPager mViewPager;//from  w  w  w .j a v  a 2s  .  c o m
    setContentView(R.layout.activity_post_swipable);
    hc = new HttpsConnector(this);

    Bundle extras = getIntent().getExtras();
    newsgroupName = extras.getString("SELECTED_NEWSGROUP");
    id = extras.getInt("SELECTED_ID");
    int selected_id = extras.getInt("GOTO_THIS");
    fromSearch = extras.getBoolean("SEARCH_RESULTS");

    ppa = new PostPagerAdapter(getSupportFragmentManager(), fromSearch);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(ppa);
    dialog = new InvalidApiKeyDialog(this);
    mViewPager.setCurrentItem(selected_id);

    if (!fromSearch) {
        for (int x = 0; x < DisplayThreadsActivity.lastFetchedThreads.size(); x++) {
            if (DisplayThreadsActivity.lastFetchedThreads.get(x).getNumber() == id) {
                rootThread = DisplayThreadsActivity.lastFetchedThreads.get(x);
                break;
            }
        }
    }
}

From source file:cn.com.hgh.view.SlideSwitch.java

@Override
protected void onRestoreInstanceState(Parcelable state) {
    if (state instanceof Bundle) {
        Bundle bundle = (Bundle) state;
        this.isOpen = bundle.getBoolean("isOpen");
        state = bundle.getParcelable("instanceState");
    }// w  w w.ja v  a  2s.c  o m
    super.onRestoreInstanceState(state);
}

From source file:com.almarsoft.GroundhogReader.ComposeActivity.java

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

    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    setContentView(R.layout.compose);//from ww w  . j  a v a  2s.  c  om

    mEdit_Groups = (EditText) this.findViewById(R.id.edit_groups);
    mEdit_Subject = (EditText) this.findViewById(R.id.edit_subject);
    mEdit_Body = (EditText) this.findViewById(R.id.edit_body);
    Button sendButton = (Button) this.findViewById(R.id.btn_send);
    Button discardButton = (Button) this.findViewById(R.id.btn_discard);

    sendButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            new AlertDialog.Builder(ComposeActivity.this).setTitle(getString(R.string.confirm_send))
                    .setMessage(getString(R.string.confirm_send_question))
                    .setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dlg, int sumthin) {
                            ComposeActivity.this.postMessage();
                        }
                    }).setNegativeButton(getString(R.string.no), null).show();
        }
    });

    discardButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            new AlertDialog.Builder(ComposeActivity.this).setTitle(getString(R.string.confirm_discard))
                    .setMessage(getString(R.string.confirm_discard_question))
                    .setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dlg, int sumthin) {
                            ComposeActivity.this.finish();
                        }
                    }).setNegativeButton(getString(R.string.no), null).show();
        }
    });

    this.setComposeSizeFromPrefs(0);

    // Get the header passed from the ; for the moment we only need the newsgroups and subject,
    // but we later will need more parts for posting

    Bundle extras = getIntent().getExtras();
    mIsNew = extras.getBoolean("isNew");
    mCurrentGroup = extras.getString("group");

    Toast.makeText(
            getApplicationContext(), getString(R.string.encoding) + ": "
                    + mPrefs.getString("postCharset", "ISO8859_15") + getString(R.string.change_encoding_tip),
            Toast.LENGTH_SHORT).show();

    if (mIsNew) {
        mEdit_Groups.setText(mCurrentGroup);
        mEdit_Subject.requestFocus();
    }

    else {

        String prevFrom = extras.getString("From");
        String prevDate = extras.getString("Date");
        String newsgroups = extras.getString("Newsgroups");
        mMessageID = extras.getString("Message-ID");
        if (extras.containsKey("References"))
            mReferences = extras.getString("References");

        if (extras.containsKey("Subject")) {
            String prevSubject = extras.getString("Subject");
            if (!prevSubject.toLowerCase().contains("re:")) {
                prevSubject = "Re: " + prevSubject;
            }
            mEdit_Subject.setText(prevSubject);
        }

        String followupOption = extras.getString("multipleFollowup");

        if (followupOption == null || !followupOption.equalsIgnoreCase("CURRENT"))
            mEdit_Groups.setText(newsgroups);
        else
            mEdit_Groups.setText(mCurrentGroup);

        mEdit_Body.setText("");

        // Get the quoted bodytext, set it and set the cursor at the configured position
        String bodyText = (String) extras.getString("bodytext");
        boolean replyCursorStart = mPrefs.getBoolean("replyCursorPositionStart", false);

        String quoteheader = mPrefs.getString("authorline", "On [date], [user] said:");
        String quotedBody = MessageTextProcessor.quoteBody(bodyText, quoteheader, prevFrom, prevDate);

        if (bodyText != null && bodyText.length() > 0) {

            if (replyCursorStart) {
                mEdit_Body.setText("\n\n" + quotedBody);
                mEdit_Body.setSelection(1);
            } else {
                mEdit_Body.setText(quotedBody + "\n\n");
                mEdit_Body.setSelection(mEdit_Body.getText().length());
            }
        }

        mEdit_Body.requestFocus();
    } // End else isNew

}

From source file:com.attentec.Login.java

/**
 * Starts the application. This method is called when login was successful.
 * @return// ww  w . ja v a 2  s  .  c o m
 */
public final void loginSuccess() {
    Log.d(TAG, "Login Success");
    //check if Login was launched for creating an account for synching
    // with phone contact list
    Bundle extras = getIntent().getExtras();
    if (extras != null && extras.getBoolean("account_create")) {
        //this means that we are creating an account for synching
        // with the phones contact list

        //We need to check if we are running a high enough version to do contact sync.
        if (mIsTwoPointOneOrHigher) {
            SyncWrapLogin.passResponse(readUserName(), getString(R.string.ACCOUNT_TYPE), this, readKey(),
                    extras);
        } else {
            Log.e(TAG, "Adding account but below 2.1, not good. Quitting...");
        }
        finish();
        return;
    }
    //Log.d(TAG, "Login end, creating intent");

    Intent myIntent = new Intent(this, Attentec.class);
    startActivity(myIntent);
    finish();
}

From source file:com.ademsha.appnotifico.NotificationDataHelper.java

@TargetApi(Build.VERSION_CODES.KITKAT)
private static JSONObject getNotificationExtras(JSONObject notification,
        StatusBarNotification statusBarNotification) {
    try {/* w ww.j a va 2  s  . c  o  m*/
        Bundle extras = statusBarNotification.getNotification().extras;
        if (extras != null) {
            notification.put("text", extras.getString(Notification.EXTRA_TEXT));
            notification.put("sub_text", extras.getString(Notification.EXTRA_SUB_TEXT));
            notification.put("summary_text", extras.getString(Notification.EXTRA_SUMMARY_TEXT));
            notification.put("text_lines", Arrays
                    .toString(extras.getCharSequenceArray(Notification.EXTRA_TEXT_LINES)).replace("null", ""));
            notification.put("icon", String.valueOf(extras.getInt(Notification.EXTRA_SMALL_ICON)));
            if (extras.getParcelable(Notification.EXTRA_LARGE_ICON) != null) {
                notification.put("large_icon",
                        String.valueOf(extras.getParcelable(Notification.EXTRA_LARGE_ICON).toString())
                                .replace("null", ""));
            }
            notification.put("title", extras.getString(Notification.EXTRA_TITLE));
            notification.put("title_big", extras.getString(Notification.EXTRA_TITLE_BIG));
            notification.put("progress", extras.getInt(Notification.EXTRA_PROGRESS));
            notification.put("progress_indeterminate",
                    String.valueOf(extras.getBoolean(Notification.EXTRA_PROGRESS_INDETERMINATE)));
            notification.put("progress_max", String.valueOf(extras.getInt(Notification.EXTRA_PROGRESS_MAX)));
            notification.put("people", extras.getStringArray(Notification.EXTRA_PEOPLE));
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return notification;
}

From source file:com.android.timezonepicker.TimeZonePickerDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    long timeMillis = 0;
    String timeZone = null;//from  w w w  . j ava 2 s .  co m
    Bundle b = getArguments();
    if (b != null) {
        timeMillis = b.getLong(BUNDLE_START_TIME_MILLIS);
        timeZone = b.getString(BUNDLE_TIME_ZONE);
    }
    boolean hideFilterSearch = false;

    if (savedInstanceState != null) {
        hideFilterSearch = savedInstanceState.getBoolean(KEY_HIDE_FILTER_SEARCH);
    }
    mView = new TimeZonePickerView(getActivity(), null, timeZone, timeMillis, this, hideFilterSearch);
    if (savedInstanceState != null && savedInstanceState.getBoolean(KEY_HAS_RESULTS, false)) {
        mView.showFilterResults(savedInstanceState.getInt(KEY_LAST_FILTER_TYPE),
                savedInstanceState.getString(KEY_LAST_FILTER_STRING),
                savedInstanceState.getInt(KEY_LAST_FILTER_TIME));
    }
    return mView;
}