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:can.yrt.onebusaway.RegionsFragment.java

@Override
public Loader<ArrayList<ObaRegion>> onCreateLoader(int id, Bundle args) {
    boolean refresh = args.getBoolean(RELOAD);
    return new ObaRegionsLoader(getActivity(), refresh);
}

From source file:com.manning.androidhacks.hack029.fragment.ColorFragment.java

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

    Bundle bundle = getArguments();//  w w  w. j a v a2 s . c  om
    if (getArguments() != null) {
        mColor = bundle.getInt(COLOR_KEY);
        mText = bundle.getString(TEXT_KEY);
        mIsLandscape = bundle.getBoolean(LANDSCAPE_KEY);
    }
}

From source file:org.andicar.service.UpdateCheckService.java

@Override
public void onStart(Intent intent, int startId) {
    super.onStart(intent, startId);

    if (getSharedPreferences(StaticValues.GLOBAL_PREFERENCE_NAME, Context.MODE_MULTI_PROCESS)
            .getBoolean("SendCrashReport", true))
        Thread.setDefaultUncaughtExceptionHandler(
                new AndiCarExceptionHandler(Thread.getDefaultUncaughtExceptionHandler(), this));

    try {/*w  w w.  jav  a  2s . c  o  m*/
        Bundle extras = intent.getExtras();
        if (extras == null || extras.getBoolean("setJustNextRun") || !extras.getBoolean("AutoUpdateCheck")) {
            setNextRun();
            stopSelf();
        }

        URL updateURL = new URL(StaticValues.VERSION_FILE_URL);
        URLConnection conn = updateURL.openConnection();
        if (conn == null)
            return;
        InputStream is = conn.getInputStream();
        if (is == null)
            return;
        BufferedInputStream bis = new BufferedInputStream(is);
        ByteArrayBuffer baf = new ByteArrayBuffer(50);
        int current = 0;
        while ((current = bis.read()) != -1) {
            baf.append((byte) current);
        }

        /* Convert the Bytes read to a String. */
        String s = new String(baf.toByteArray());
        /* Get current Version Number */
        int curVersion = getPackageManager().getPackageInfo("org.andicar.activity", 0).versionCode;
        int newVersion = Integer.valueOf(s);

        /* Is a higher version than the current already out? */
        if (newVersion > curVersion) {
            //get the whats new message
            updateURL = new URL(StaticValues.WHATS_NEW_FILE_URL);
            conn = updateURL.openConnection();
            if (conn == null)
                return;
            is = conn.getInputStream();
            if (is == null)
                return;
            bis = new BufferedInputStream(is);
            baf = new ByteArrayBuffer(50);
            current = 0;
            while ((current = bis.read()) != -1) {
                baf.append((byte) current);
            }

            /* Convert the Bytes read to a String. */
            s = new String(baf.toByteArray());

            mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
            notification = null;
            Intent i = new Intent(this, WhatsNewDialog.class);
            i.putExtra("UpdateMsg", s);
            PendingIntent contentIntent = PendingIntent.getActivity(UpdateCheckService.this, 0, i, 0);

            CharSequence title = getText(R.string.Notif_UpdateTitle);
            String message = getString(R.string.Notif_UpdateMsg);
            notification = new Notification(R.drawable.icon_sys_info, message, System.currentTimeMillis());
            notification.flags |= Notification.DEFAULT_LIGHTS;
            notification.flags |= Notification.DEFAULT_SOUND;
            notification.flags |= Notification.FLAG_AUTO_CANCEL;
            notification.setLatestEventInfo(UpdateCheckService.this, title, message, contentIntent);
            mNM.notify(StaticValues.NOTIF_UPDATECHECK_ID, notification);
            setNextRun();
        }
        stopSelf();
    } catch (Exception e) {
        Log.i("UpdateService", "Service failed.");
        e.printStackTrace();
    }
}

From source file:com.normalexception.app.rx8club.task.AdminTask.java

@Override
protected void onPostExecute(Void result) {
    try {//w w  w. j  a v a  2  s.co  m
        mProgressDialog.dismiss();
        mProgressDialog = null;
    } catch (Exception e) {
        Log.w(TAG, e.getMessage());
    }

    if (doType == LOCK_THREAD) {
        Bundle args = sourceFragment.getArguments();
        boolean isLocked = args.getBoolean("locked");
        Log.d(TAG, "Setting Thread Lock To: " + !isLocked);
        args.putBoolean("locked", !isLocked);

        // Create new fragment and transaction
        Fragment newFragment = ThreadFragment.newInstance();

        FragmentUtils.fragmentTransaction(sourceFragment.getActivity(), newFragment, true, true, args);
    } else if (doType == MOVE_THREAD) {
        MoveThreadDialog mtd = new MoveThreadDialog(sourceFragment, token, thread, threadTitle, selectOptions);
        mtd.show();
    } else {
        //this.sourceFragment.finish();
        sourceFragment.getFragmentManager().popBackStack();
    }
}

From source file:dk.moerks.ratebeermobile.MailAction.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mailaction);

    final boolean replyMode;
    final String messageId;
    final String from;
    final String senderId;
    final String subject;
    final String message;
    Bundle extras = getIntent().getExtras();

    if (extras != null) {
        replyMode = extras.getBoolean("ISREPLY");
        if (replyMode) {
            messageId = extras.getString("MESSAGEID");
            from = extras.getString("SENDER");
            senderId = extras.getString("SENDERID");
            subject = extras.getString("SUBJECT");
            message = extras.getString("MESSAGE");
            extras.putString("CURRENT_USER_ID", null);

            EditText fromText = (EditText) findViewById(R.id.mail_action_to);
            fromText.setEnabled(false);// w w w . ja  v  a  2 s .  c o  m
            EditText subjectText = (EditText) findViewById(R.id.mail_action_subject);
            EditText messageText = (EditText) findViewById(R.id.mail_action_message);

            fromText.setText(from);
            subjectText.setText(subject);
            messageText.setText("\n\n......................................................\n" + message);
        } else {
            messageId = null;
            from = null;
            senderId = null;
            subject = null;
            message = null;
        }
    } else {
        replyMode = false;
        messageId = null;
        from = null;
        senderId = null;
        subject = null;
        message = null;
    }

    Button sendMailButton = (Button) findViewById(R.id.sendMailButton);
    sendMailButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            EditText fromText = (EditText) findViewById(R.id.mail_action_to);
            EditText subjectText = (EditText) findViewById(R.id.mail_action_subject);
            EditText messageText = (EditText) findViewById(R.id.mail_action_message);

            // Prepare the 'send' action
            List<NameValuePair> parameters = new ArrayList<NameValuePair>();
            if (replyMode) {
                parameters.add(new BasicNameValuePair("UserID", senderId));
                parameters.add(new BasicNameValuePair("MessID", messageId));
                parameters.add(new BasicNameValuePair("Referrer",
                        "http://ratebeer.com/showmessage/" + messageId + "/"));
                parameters.add(new BasicNameValuePair("text2", from));
                parameters.add(new BasicNameValuePair("Subject", subject));
                parameters.add(new BasicNameValuePair("Body", messageText.getText().toString()));
                parameters.add(new BasicNameValuePair("nAllowEmail", "0"));
                parameters.add(new BasicNameValuePair("nCc", "0"));
                parameters.add(new BasicNameValuePair("nCcEmail", "android@moerks.dk"));
                parameters.add(new BasicNameValuePair("nCcEmail2", "android@moerks.dk"));
            } else {
                Log.d(LOGTAG, "USERID: " + getUserId());
                parameters.add(new BasicNameValuePair("nSource", getUserId())); //MY User Id
                parameters.add(new BasicNameValuePair("Referrer", "http://ratebeer.com/inbox"));
                parameters.add(new BasicNameValuePair("UserID", "0"));
                parameters.add(new BasicNameValuePair("RecipientName", fromText.getText().toString()));
                parameters.add(new BasicNameValuePair("Subject", subjectText.getText().toString()));
                parameters.add(new BasicNameValuePair("Body", messageText.getText().toString()));
                parameters.add(new BasicNameValuePair("nAllowEmail", "1"));
                parameters.add(new BasicNameValuePair("nCc", "0"));
                parameters.add(new BasicNameValuePair("nCcEmail", "android@moerks.dk"));
                parameters.add(new BasicNameValuePair("nCcEmail2", "android@moerks.dk"));
            }

            new SendBeermailTask(MailAction.this, replyMode)
                    .execute(parameters.toArray(new NameValuePair[] {}));
        }
    });
}

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

/**
 * Add param value from Bundle to JsonObject
 * //from   ww  w  .  j  a va2  s  . com
 * @param obj
 * @param params
 */
public void addToJson(JSONObject obj, Bundle params) {
    if (params.containsKey(name())) {
        try {
            switch (type) {
            case BOOLEAN:
                obj.put(name(), params.getBoolean(name()));
                break;
            case FLOAT:
                obj.put(name(), params.getFloat(name()));
                break;
            case INTEGER:
                obj.put(name(), params.getInt(name()));
                break;
            case STRING:
                obj.put(name(), params.getString(name()));
                break;
            default:
            }
        } catch (JSONException e) {
            Log.w(TAG, "Unable to add param " + this + " to json");
        }
    }
}

From source file:au.gov.ga.worldwind.androidremote.client.ui.ItemModelFragment.java

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

    Bundle arguments = getArguments();
    int itemModelStateId = arguments.getInt(ITEM_MODEL_STATE_ID_KEY);
    state = stateProvider.getItemModelState(itemModelStateId);
    flatten = arguments.getBoolean(FLATTEN_KEY);
    menuProvider = stateProvider.getMenuProvider(itemModelStateId);

    handler = new Handler();

    setHasOptionsMenu(menuProvider.hasOptionsMenu());
}

From source file:com.facebook.internal.BundleJSONConverterTests.java

@SmallTest
public void testSimpleValues() throws JSONException {
    ArrayList<String> arrayList = new ArrayList<String>();
    arrayList.add("1st");
    arrayList.add("2nd");
    arrayList.add("third");

    Bundle innerBundle1 = new Bundle();
    innerBundle1.putInt("inner", 1);

    Bundle innerBundle2 = new Bundle();
    innerBundle2.putString("inner", "2");
    innerBundle2.putStringArray("deep list", new String[] { "7", "8" });

    innerBundle1.putBundle("nested bundle", innerBundle2);

    Bundle b = new Bundle();
    b.putBoolean("boolValue", true);
    b.putInt("intValue", 7);
    b.putLong("longValue", 5000000000l);
    b.putDouble("doubleValue", 3.14);
    b.putString("stringValue", "hello world");
    b.putStringArray("stringArrayValue", new String[] { "first", "second" });
    b.putStringArrayList("stringArrayListValue", arrayList);
    b.putBundle("nested", innerBundle1);

    JSONObject json = BundleJSONConverter.convertToJSON(b);
    assertNotNull(json);/*from ww w .java  2  s. c  o  m*/

    assertEquals(true, json.getBoolean("boolValue"));
    assertEquals(7, json.getInt("intValue"));
    assertEquals(5000000000l, json.getLong("longValue"));
    assertEquals(3.14, json.getDouble("doubleValue"));
    assertEquals("hello world", json.getString("stringValue"));

    JSONArray jsonArray = json.getJSONArray("stringArrayValue");
    assertEquals(2, jsonArray.length());
    assertEquals("first", jsonArray.getString(0));
    assertEquals("second", jsonArray.getString(1));

    jsonArray = json.getJSONArray("stringArrayListValue");
    assertEquals(3, jsonArray.length());
    assertEquals("1st", jsonArray.getString(0));
    assertEquals("2nd", jsonArray.getString(1));
    assertEquals("third", jsonArray.getString(2));

    JSONObject innerJson = json.getJSONObject("nested");
    assertEquals(1, innerJson.getInt("inner"));
    innerJson = innerJson.getJSONObject("nested bundle");
    assertEquals("2", innerJson.getString("inner"));

    jsonArray = innerJson.getJSONArray("deep list");
    assertEquals(2, jsonArray.length());
    assertEquals("7", jsonArray.getString(0));
    assertEquals("8", jsonArray.getString(1));

    Bundle finalBundle = BundleJSONConverter.convertToBundle(json);
    assertNotNull(finalBundle);

    assertEquals(true, finalBundle.getBoolean("boolValue"));
    assertEquals(7, finalBundle.getInt("intValue"));
    assertEquals(5000000000l, finalBundle.getLong("longValue"));
    assertEquals(3.14, finalBundle.getDouble("doubleValue"));
    assertEquals("hello world", finalBundle.getString("stringValue"));

    List<String> stringList = finalBundle.getStringArrayList("stringArrayValue");
    assertEquals(2, stringList.size());
    assertEquals("first", stringList.get(0));
    assertEquals("second", stringList.get(1));

    stringList = finalBundle.getStringArrayList("stringArrayListValue");
    assertEquals(3, stringList.size());
    assertEquals("1st", stringList.get(0));
    assertEquals("2nd", stringList.get(1));
    assertEquals("third", stringList.get(2));

    Bundle finalInnerBundle = finalBundle.getBundle("nested");
    assertEquals(1, finalInnerBundle.getInt("inner"));
    finalBundle = finalInnerBundle.getBundle("nested bundle");
    assertEquals("2", finalBundle.getString("inner"));

    stringList = finalBundle.getStringArrayList("deep list");
    assertEquals(2, stringList.size());
    assertEquals("7", stringList.get(0));
    assertEquals("8", stringList.get(1));
}

From source file:augsburg.se.alltagsguide.utilities.ui.BasePageWebViewLanguageActivity.java

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
    mTranslatedDismissed = savedInstanceState.getBoolean(TRANSLATED_DISMISSED);
    Serializable savedInstance = savedInstanceState.getSerializable(PAGE_STATE);
    setPageFromSerializable(savedInstance);
}

From source file:fr.cph.chicago.activity.BaseActivity.java

@Override
public final void onRestoreInstanceState(final Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    mError = savedInstanceState.getBoolean("error");
}