Example usage for android.os Bundle getString

List of usage examples for android.os Bundle getString

Introduction

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

Prototype

@Nullable
public String getString(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:com.ibuildapp.romanblack.MultiContactsPlugin.MultiContactsActivity.java

@Override
public void create() {
    try {/*from   w  w  w .  ja v  a  2s . c o m*/
        setContentView(R.layout.grouped_contacts_main);

        setTopBarLeftButtonTextAndColor(getResources().getString(R.string.common_back_upper),
                getResources().getColor(android.R.color.black), true, new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        finish();
                        return;
                    }
                });
        setTopBarTitleColor(getResources().getColor(android.R.color.black));
        setTopBarBackgroundColor(Statics.color1);

        LinearLayout inputSearchLayout = (LinearLayout) findViewById(R.id.grouped_contacts_search_layout);
        inputSearchLayout.setVisibility(View.GONE);

        resources = getResources();

        Intent currentIntent = getIntent();
        Bundle store = currentIntent.getExtras();
        widget = (Widget) store.getSerializable("Widget");
        category = store.getString("category");
        setTopBarTitle(category);

        if (widget == null) {
            handler.sendEmptyMessage(INITIALIZATION_FAILED);
            return;
        }

        cachePath = widget.getCachePath() + "/contacts-" + widget.getOrder();

        root = (LinearLayout) findViewById(R.id.grouped_contacts_main_root);
        listView = (ListView) findViewById(R.id.grouped_contacts_list);
        separator = findViewById(R.id.gc_head_separator);
        backSeparator = findViewById(R.id.gc_back_separator);

        backSeparator.setBackgroundColor(Statics.color1);
        if (Statics.isLight) {
            separator.setBackgroundColor(Color.parseColor("#4d000000"));
        } else {
            separator.setBackgroundColor(Color.parseColor("#4dFFFFFF"));
        }

        handler.sendEmptyMessage(SET_ROOT_BACKGROUND);
    } catch (Exception e) {
    }
}

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  2 s.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:yulei.android.client.AndroidMobilePushApp.java

private String getMessage(int numOfMissedMessages) {
    String message = "";
    String linesOfMessageCount = getString(R.string.lines_of_message_count);
    if (numOfMissedMessages > 0) {
        String plural = numOfMissedMessages > 1 ? "s" : "";
        Log.i("onResume", "missed " + numOfMissedMessages + " message" + plural);
        tView.append("You missed " + numOfMissedMessages + " message" + plural + ". Your most recent was:\n");
        for (int i = 0; i < savedValues.getInt(linesOfMessageCount, 0); i++) {
            String line = "***" + savedValues.getString("MessageLine" + i, "") + "&&&&";
            message += (line + "\n");
        }//from   w  w w.j a va 2s  .c om
        NotificationManager mNotification = (NotificationManager) getSystemService(
                Context.NOTIFICATION_SERVICE);
        mNotification.cancel(R.string.notification_number);
        SharedPreferences.Editor editor = savedValues.edit();
        editor.putInt(this.numOfMissedMessages, 0);
        editor.putInt(linesOfMessageCount, 0);
        editor.commit();
    } else {
        Log.i("onResume", "no missed messages");
        Intent intent = getIntent();
        if (intent != null) {
            Bundle extras = intent.getExtras();
            if (extras != null) {

                String realData = extras.getString("default");
                // message += "___" +realData +"___";
                if (realData != null && realData.length() > 2) {
                    //addMarker(decodeJSONforLat(realData),decodeJSONforLon(realData));

                    if (realData.length() > 2) {
                        Log.e("here", realData);
                        try {

                            Toast toast = Toast.makeText(getApplicationContext(),
                                    decodeJSONforName(realData) + decodeJSONforTime(realData),
                                    Toast.LENGTH_SHORT);
                            toast.show();
                            Log.e("heres", "sssss");
                            //addMarker(decodeJSONforLat(realData),decodeJSONforLon(realData));
                            addMarker(decodeJSONforLat(realData), decodeJSONforLon(realData),
                                    decodeJSONforName(realData), decodeJSONforSentiment(realData),
                                    decodeJSONforScore(realData));
                            message = "\n" + decodeJSONforName(realData) + "\n" + decodeJSONforContent(realData)
                                    + "\n";
                            addHeatMap(decodeJSONforLat(realData), decodeJSONforLon(realData));
                            //addMarker((Double)decodeObj.get("latitute"),(Double)decodeObj.get("longitude"),(String)decodeObj.get("time"),(String)decodeObj.get("userName"));
                        } catch (Exception e) {
                            Log.e("exception", "Exception throwed");
                        }
                    }
                }
            }
        }
    }
    message += "\n";
    return message;
}

From source file:com.arubadesignweb.app.appoverview.util.GcmIntentService.java

/** GEOLOCATED PUSH NOTIFICATIONS **/
private void addProximityAlert(Bundle extras, Location target_location, double radius) {

    try {/*  w  ww .java 2 s. c  o  m*/
        JSONObject alert = new JSONObject();
        alert.put("latitude", target_location.getLatitude());
        alert.put("longitude", target_location.getLongitude());
        alert.put("radius", radius);
        alert.put("title", extras.getString("title"));
        alert.put("message", extras.getString("message"));
        alert.put("send_until", extras.getString("send_until"));
        alert.put("message_id", extras.getString("message_id"));

        String key = "push" + extras.getString("message_id");
        SharedPreferences push_prefs = getSharedPreferences("geolocated_push", Context.MODE_APPEND);
        SharedPreferences.Editor editor = push_prefs.edit();
        editor.putString(key, alert.toString());
        editor.commit();
    } catch (JSONException e) {
        e.printStackTrace();
    }

}

From source file:br.com.ufc.palestrasufc.twitter.Util.java

/**
 * Connect to an HTTP URL and return the response as a string.
 * /*from ww  w  . j av  a 2  s.c  o  m*/
 * Note that the HTTP method override is used on non-GET requests. (i.e.
 * requests are made as "POST" with method specified in the body).
 * 
 * @param url - the resource to open: must be a welformed URL
 * @param method - the HTTP method to use ("GET", "POST", etc.)
 * @param params - the query parameter for the URL (e.g. access_token=foo)
 * @return the URL contents as a String
 * @throws MalformedURLException - if the URL format is invalid
 * @throws IOException - if a network problem occurs
 */
public static String openUrl(String url, String method, Bundle params)
        throws MalformedURLException, IOException {
    // random string as boundary for multi-part http post
    String strBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f";
    String endLine = "\r\n";

    OutputStream os;

    if (method.equals("GET")) {
        url = url + "?" + encodeUrl(params);
    }
    Log.d("Twitter-Util", method + " URL: " + url);
    HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
    conn.setRequestProperty("User-Agent",
            System.getProperties().getProperty("http.agent") + " TwitterAndroidSDK");
    if (!method.equals("GET")) {
        Bundle dataparams = new Bundle();
        for (String key : params.keySet()) {
            if (params.getByteArray(key) != null) {
                dataparams.putByteArray(key, params.getByteArray(key));
            }
        }

        // use method override
        if (!params.containsKey("method")) {
            params.putString("method", method);
        }

        if (params.containsKey("access_token")) {
            String decoded_token = URLDecoder.decode(params.getString("access_token"));
            params.putString("access_token", decoded_token);
        }

        conn.setRequestMethod("POST");
        conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + strBoundary);
        conn.setDoOutput(true);
        conn.setDoInput(true);
        conn.setRequestProperty("Connection", "Keep-Alive");
        conn.connect();
        os = new BufferedOutputStream(conn.getOutputStream());

        os.write(("--" + strBoundary + endLine).getBytes());
        os.write((encodePostBody(params, strBoundary)).getBytes());
        os.write((endLine + "--" + strBoundary + endLine).getBytes());

        if (!dataparams.isEmpty()) {

            for (String key : dataparams.keySet()) {
                os.write(("Content-Disposition: form-data; filename=\"" + key + "\"" + endLine).getBytes());
                os.write(("Content-Type: content/unknown" + endLine + endLine).getBytes());
                os.write(dataparams.getByteArray(key));
                os.write((endLine + "--" + strBoundary + endLine).getBytes());

            }
        }
        os.flush();
    }

    String response = "";
    try {
        response = read(conn.getInputStream());
    } catch (FileNotFoundException e) {
        // Error Stream contains JSON that we can parse to a FB error
        response = read(conn.getErrorStream());
    }
    return response;
}

From source file:net.idlesoft.android.apps.github.activities.Commit.java

@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.commit);//from  ww  w. j  a v a2 s  .  c  o m

    mPrefs = getSharedPreferences(Hubroid.PREFS_NAME, 0);

    mUsername = mPrefs.getString("username", "");
    mPassword = mPrefs.getString("password", "");

    mGapi.authenticate(mUsername, mPassword);

    ((ImageButton) findViewById(R.id.btn_search)).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            startActivity(new Intent(Commit.this, Search.class));
        }
    });

    mCommitLayout = (ScrollView) findViewById(R.id.sv_commit_content);
    mProgressLayout = (RelativeLayout) findViewById(R.id.rl_commit_progressLayout);

    final Bundle extras = getIntent().getExtras();
    if (extras != null) {
        mRepositoryName = extras.getString("repo_name");
        mRepositoryOwner = extras.getString("repo_owner");
        mCommitSha = extras.getString("commit_sha");
        mCommitter = extras.getString("committer");
        mAuthor = extras.getString("author");
    }
}

From source file:com.ibm.mobilefirstplatform.clientsdk.android.push.internal.MFPInternalPushMessage.java

public MFPInternalPushMessage(Intent intent) {

    Bundle info = intent.getExtras();
    MFPPushUtils.dumpIntent(intent);/*from w w  w . j  av a 2s .  com*/

    alert = info.getString(GCM_EXTRA_ALERT);
    url = info.getString(GCM_EXTRA_URL);
    payload = info.getString(GCM_EXTRA_PAYLOAD);
    sound = info.getString(GCM_EXTRA_SOUND);
    bridge = info.getBoolean(GCM_EXTRA_BRIDGE);
    priority = info.getString(GCM_EXTRA_PRIORITY);
    visibility = info.getString(GCM_EXTRA_VISIBILITY);
    redact = info.getString(GCM_EXTRA_REDACT);
    key = info.getString(GCM_EXTRA_KEY);
    category = info.getString(GCM_EXTRA_CATEGORY);
    gcmStyle = info.getString(GCM_EXTRA_STYLE);
    iconName = info.getString(GCM_EXTRA_ICONNAME);
    notificationId = info.getInt(GCM_EXTRA_NOTIFICATIONID);

    try {
        JSONObject towers = new JSONObject(payload);
        id = towers.getString(GCM_EXTRA_ID);
    } catch (JSONException e) {
        logger.error(
                "MFPInternalPushMessage: MFPInternalPushMessage() - Exception while parsing JSON, get id.  "
                        + e.toString());
    }
}

From source file:com.jiramot.foursquare.android.Util.java

/**
 * Connect to an HTTP URL and return the response as a string.
 *
 * Note that the HTTP method override is used on non-GET requests. (i.e.
 * requests are made as "POST" with method specified in the body).
 *
 * @param url - the resource to open: must be a welformed URL
 * @param method - the HTTP method to use ("GET", "POST", etc.)
 * @param params - the query parameter for the URL (e.g. access_token=foo)
 * @return the URL contents as a String//from  w  ww  .  j av a  2  s .  c  o  m
 * @throws MalformedURLException - if the URL format is invalid
 * @throws IOException - if a network problem occurs
 */
public static String openUrl(String url, String method, Bundle params)
        throws MalformedURLException, IOException {
    // random string as boundary for multi-part http post
    String strBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f";
    String endLine = "\r\n";

    OutputStream os;

    if (method.equals("GET")) {
        url = url + "?" + encodeUrl(params);
    }
    Log.d("Foursquare-Util", method + " URL: " + url);
    HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
    conn.setRequestProperty("User-Agent",
            System.getProperties().getProperty("http.agent") + " FoursquareAndroidSDK");
    if (!method.equals("GET")) {
        Bundle dataparams = new Bundle();
        for (String key : params.keySet()) {
            if (params.getByteArray(key) != null) {
                dataparams.putByteArray(key, params.getByteArray(key));
            }
        }

        // use method override
        if (!params.containsKey("method")) {
            params.putString("method", method);
        }

        if (params.containsKey("access_token")) {
            String decoded_token = URLDecoder.decode(params.getString("access_token"));
            params.putString("access_token", decoded_token);
        }

        conn.setRequestMethod("POST");
        conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + strBoundary);
        conn.setDoOutput(true);
        conn.setDoInput(true);
        conn.setRequestProperty("Connection", "Keep-Alive");
        conn.connect();
        os = new BufferedOutputStream(conn.getOutputStream());

        os.write(("--" + strBoundary + endLine).getBytes());
        os.write((encodePostBody(params, strBoundary)).getBytes());
        os.write((endLine + "--" + strBoundary + endLine).getBytes());

        if (!dataparams.isEmpty()) {

            for (String key : dataparams.keySet()) {
                os.write(("Content-Disposition: form-data; filename=\"" + key + "\"" + endLine).getBytes());
                os.write(("Content-Type: content/unknown" + endLine + endLine).getBytes());
                os.write(dataparams.getByteArray(key));
                os.write((endLine + "--" + strBoundary + endLine).getBytes());

            }
        }
        os.flush();
    }

    String response = "";
    try {
        response = read(conn.getInputStream());
    } catch (FileNotFoundException e) {
        // Error Stream contains JSON that we can parse to a FB error
        response = read(conn.getErrorStream());
    }
    return response;
}

From source file:com.qburst.android.linkedin.Util.java

/**
 * Connect to an HTTP URL and return the response as a string.
 * /*from   w w w.  j a v  a 2 s.c om*/
 * Note that the HTTP method override is used on non-GET requests. (i.e.
 * requests are made as "POST" with method specified in the body).
 * 
 * @param url - the resource to open: must be a welformed URL
 * @param method - the HTTP method to use ("GET", "POST", etc.)
 * @param params - the query parameter for the URL (e.g. access_token=foo)
 * @return the URL contents as a String
 * @throws MalformedURLException - if the URL format is invalid
 * @throws IOException - if a network problem occurs
 */
public static String openUrl(String url, String method, Bundle params)
        throws MalformedURLException, IOException {
    // random string as boundary for multi-part http post
    String strBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f";
    String endLine = "\r\n";

    OutputStream os;

    if (method.equals("GET")) {
        url = url + "?" + encodeUrl(params);
    }
    Log.d("Twitter-Util", method + " URL: " + url);
    HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
    conn.setRequestProperty("User-Agent",
            System.getProperties().getProperty("http.agent") + " LinkedInAndroidSDK");
    if (!method.equals("GET")) {
        Bundle dataparams = new Bundle();
        for (String key : params.keySet()) {
            if (params.getByteArray(key) != null) {
                dataparams.putByteArray(key, params.getByteArray(key));
            }
        }

        // use method override
        if (!params.containsKey("method")) {
            params.putString("method", method);
        }

        if (params.containsKey("access_token")) {
            String decoded_token = URLDecoder.decode(params.getString("access_token"));
            params.putString("access_token", decoded_token);
        }

        conn.setRequestMethod("POST");
        conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + strBoundary);
        conn.setDoOutput(true);
        conn.setDoInput(true);
        conn.setRequestProperty("Connection", "Keep-Alive");
        conn.connect();
        os = new BufferedOutputStream(conn.getOutputStream());

        os.write(("--" + strBoundary + endLine).getBytes());
        os.write((encodePostBody(params, strBoundary)).getBytes());
        os.write((endLine + "--" + strBoundary + endLine).getBytes());

        if (!dataparams.isEmpty()) {

            for (String key : dataparams.keySet()) {
                os.write(("Content-Disposition: form-data; filename=\"" + key + "\"" + endLine).getBytes());
                os.write(("Content-Type: content/unknown" + endLine + endLine).getBytes());
                os.write(dataparams.getByteArray(key));
                os.write((endLine + "--" + strBoundary + endLine).getBytes());

            }
        }
        os.flush();
    }

    String response = "";
    try {
        response = read(conn.getInputStream());
    } catch (FileNotFoundException e) {
        // Error Stream contains JSON that we can parse to a FB error
        response = read(conn.getErrorStream());
    }
    return response;
}

From source file:com.purplefrog.glitchclocka.LearningReadout.java

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

    learningState = savedInstanceState.getParcelable("learningState");
    glitch.accessToken = savedInstanceState.getString("glitchToken");
}