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.partypoker.poker.engagement.reach.EngagementReachAgent.java

/**
 * GCM & ADM push payload values are always strings unfortunately. We have to parse numbers.
 * @param bundle bundle./*  www  . j  a  v  a 2 s  . co  m*/
 * @param key key to extract
 * @param defaultValue default value if key is missing or not an int.
 * @return string value parsed as an int.
 */
private static int parseInt(Bundle bundle, String key, int defaultValue) {
    try {
        return Integer.parseInt(bundle.getString(key));
    } catch (RuntimeException e) {
        return defaultValue;
    }
}

From source file:crow.weibo.tencent.TencentWeibo.java

@Override
public RequestToken getOAuthRequestToken(String callback_url) throws WeiboException {
    // ?/*from   w ww  . j  a  v a  2 s  . c o  m*/
    List<PostParameter> parameters = new ArrayList<PostParameter>();
    String oauth_timestamp = WeiboUtil.generateTimeStamp();
    String oauth_nonce = WeiboUtil.generateNonce();

    parameters.add(new PostParameter("oauth_consumer_key", getApiKey()));
    parameters.add(new PostParameter("oauth_signature_method", oauth_signature_method));
    parameters.add(new PostParameter("oauth_timestamp", oauth_timestamp));
    parameters.add(new PostParameter("oauth_nonce", oauth_nonce));
    if (!Util.isEmpty(callback_url)) {
        parameters.add(new PostParameter("oauth_callback", callback_url));
    }
    parameters.add(new PostParameter("oauth_version", oauth_version));

    String signature = makeSign(parameters, RequestTokenURL, GET_METHOD, getApiSecret(), "");
    parameters.add(new PostParameter("oauth_signature", signature));

    String queryString = WeiboUtil.encodeParameters(parameters, "&", false);

    String url = Util.isEmpty(queryString) ? RequestTokenURL : RequestTokenURL + "?" + queryString;
    try {
        String result = Util.urlGet(url);
        Bundle token = WeiboUtil.parseToken(result);
        String apikey = token.getString("oauth_token");
        String apisecret = token.getString("oauth_token_secret");
        if (apikey != null && apisecret != null) {
            return new TencentRequestToken(this, callback_url, apikey, apisecret);
        } else {
            throw new WeiboException("??");
        }
    } catch (Exception e) {
        throw new WeiboException(e);
    }
}

From source file:edu.mit.media.funf.funftowotk.MainPipeline.java

public Boolean checkValidData(Bundle data) {

    String probe = data.getString("PROBE").replace(SettingsActivity.probe_prefix, "");

    if (probe.equals("CallLogProbe")) {

        ArrayList calls = (ArrayList) data.get("CALLS");

        if (calls.isEmpty()) {
            //Log.i("DataLog",calls.toString());
            return false;
        }//from w  w  w.  ja v  a  2 s .  c om
    } else if (probe.equals("SMSProbe")) {

        ArrayList messages = (ArrayList) data.get("MESSAGES");

        if (messages.isEmpty()) {
            //Log.i("DataLog",messages.toString());
            return false;
        }
    }

    return true;
}

From source file:com.groupme.sdk.util.HttpUtilsTest.java

public void testSetHttpParamsPost() {
    MockHttpClient client = new MockHttpClient();
    client.setContext(getContext());/* w  ww. ja  v a  2s  .com*/
    String response = null;

    try {
        Bundle params = new Bundle();
        params.putString("group", "mygroup");
        params.putString("format", "json");

        response = HttpUtils.openUrl(client, OK_REQUEST, HttpUtils.METHOD_POST, null, params, null);
    } catch (HttpResponseException e) {
        fail("Received a response exception: " + e.toString());
    }

    try {
        HttpPost request = (HttpPost) client.getRequest();
        InputStream in = request.getEntity().getContent();
        BufferedReader r = new BufferedReader(new InputStreamReader(in), 1000);
        StringBuilder sb = new StringBuilder();

        for (String line = r.readLine(); line != null; line = r.readLine()) {
            sb.append(line);
        }

        assertTrue(!sb.toString().equals(""));

        Bundle bodyParams = HttpUtils.decodeParams(sb.toString());
        assertEquals("mygroup", bodyParams.getString("group"));
        assertEquals("json", bodyParams.getString("format"));
    } catch (IOException e) {
        fail("Error reading post body: " + e.toString());
    }

    if (response == null) {
        fail("Unexpected empty response");
    }
}

From source file:org.adblockplus.android.CrashReportDialog.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_LEFT_ICON);
    setContentView(R.layout.crashreport);

    Bundle extras = getIntent().getExtras();
    if (extras == null) {
        finish();//from  w ww  . j a  va 2s .co  m
        return;
    }
    report = extras.getString("report");

    getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.ic_dialog_alert);
}

From source file:crow.weibo.tencent.TencentWeibo.java

public TencentAccessToken getAccessToken(String requestToken, String requestTokenSecret, String verifier)
        throws WeiboException {
    List<PostParameter> parameters = new ArrayList<PostParameter>();

    String oauth_timestamp = WeiboUtil.generateTimeStamp();
    String oauth_nonce = WeiboUtil.generateNonce();

    parameters.add(new PostParameter("oauth_consumer_key", getApiKey()));
    parameters.add(new PostParameter("oauth_nonce", oauth_nonce));
    parameters.add(new PostParameter("oauth_signature_method", oauth_signature_method));
    parameters.add(new PostParameter("oauth_timestamp", oauth_timestamp));
    parameters.add(new PostParameter("oauth_token", requestToken));
    parameters.add(new PostParameter("oauth_verifier", verifier));
    parameters.add(new PostParameter("oauth_version", oauth_version));

    String signature = makeSign(parameters, AccessTokenURL, GET_METHOD, getApiSecret(), requestTokenSecret);
    parameters.add(new PostParameter("oauth_signature", signature));

    String queryString = WeiboUtil.encodeParameters(parameters, "&", false);

    String url = Util.isEmpty(queryString) ? AccessTokenURL : AccessTokenURL + "?" + queryString;
    try {//from www.j  a  va 2 s.c  o  m
        String result = Util.urlGet(url);
        Bundle bundle = WeiboUtil.parseToken(result);
        String token = bundle.getString("oauth_token");
        String tokenSecret = bundle.getString("oauth_token_secret");
        if (token != null && tokenSecret != null) {
            SharedPreferences pref = context.getSharedPreferences(Weibo.PREF_WEIBO, Context.MODE_PRIVATE);
            pref.edit().putString(PREF_ACCESSTOKEN, token).putString(PREF_ACCESSTOKEN_SECRET, tokenSecret)
                    .commit();
            return new TencentAccessToken(this, token, tokenSecret);
        } else {
            throw new WeiboException("??");
        }
    } catch (Exception e) {
        throw new WeiboException(e);
    }
}

From source file:com.facebook.android.FriendsList.java

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

    mHandler = new Handler();
    setContentView(R.layout.friends_list);

    Bundle extras = getIntent().getExtras();
    String apiResponse = extras.getString("API_RESPONSE");
    graph_or_fql = extras.getString("METHOD");
    try {/*w w w.  ja  va  2s . c  o m*/
        if (graph_or_fql.equals("graph")) {
            jsonArray = new JSONObject(apiResponse).getJSONArray("data");
        } else {
            jsonArray = new JSONArray(apiResponse);
        }
    } catch (JSONException e) {
        showToast("Error: " + e.getMessage());
        return;
    }
    friendsList = (ListView) findViewById(R.id.friends_list);
    friendsList.setOnItemClickListener(this);
    friendsList.setAdapter(new FriendListAdapter(this));

    showToast(getString(R.string.can_post_on_wall));
}

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

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

    final SharedPreferences prefs = getSharedPreferences(Hubroid.PREFS_NAME, 0);
    mUsername = prefs.getString("username", "");
    mPassword = prefs.getString("password", "");

    mGapi.authenticate(mUsername, mPassword);

    mListView = (ListView) getLayoutInflater().inflate(R.layout.tab_listview, null);
    mListView.setOnItemClickListener(mOnListItemClick);

    setContentView(mListView);//from  www . j  a  v  a  2  s. c om

    mAdapter = new IssuesListAdapter(ClosedIssues.this, mListView);

    final Bundle extras = getIntent().getExtras();
    if (extras != null) {
        mRepositoryOwner = extras.getString("repo_owner");
        mRepositoryName = extras.getString("repo_name");
    }

    mTask = (ClosedIssuesTask) getLastNonConfigurationInstance();
    if ((mTask == null) || (mTask.getStatus() == AsyncTask.Status.FINISHED)) {
        mTask = new ClosedIssuesTask();
    }
    mTask.activity = this;
    if (mTask.getStatus() == AsyncTask.Status.PENDING) {
        mTask.execute();
    }
}

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

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

    final SharedPreferences prefs = getSharedPreferences(Hubroid.PREFS_NAME, 0);
    mUsername = prefs.getString("username", "");
    mPassword = prefs.getString("password", "");

    mGapi.authenticate(mUsername, mPassword);

    mListView = (ListView) getLayoutInflater().inflate(R.layout.tab_listview, null);
    mListView.setOnItemClickListener(mOnListItemClick);

    setContentView(mListView);//from   w ww.  j  a  v  a2s. c  o  m

    mAdapter = new IssuesListAdapter(OpenIssues.this, mListView);

    final Bundle extras = getIntent().getExtras();
    if (extras != null) {
        mRepositoryOwner = extras.getString("repo_owner");
        mRepositoryName = extras.getString("repo_name");
    }

    mTask = (OpenIssuesTask) getLastNonConfigurationInstance();
    if ((mTask == null) || (mTask.getStatus() == AsyncTask.Status.FINISHED)) {
        mTask = new OpenIssuesTask();
    }
    mTask.activity = this;
    if (mTask.getStatus() == AsyncTask.Status.PENDING) {
        mTask.execute();
    }
}

From source file:com.ntsync.android.sync.activities.LoginProgressDialog.java

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

    Bundle args = getArguments();
    String username = args.getString(PARAM_USERNAME);
    String password = args.getString(PARAM_PWD);

    // Retain to keep Task during conf changes
    setRetainInstance(true);/*from  w w  w.  j ava  2  s  .com*/
    setCancelable(false);

    loginTask = new UserLoginTask(username, password);
    loginTask.execute();
}