Example usage for android.os Bundle putString

List of usage examples for android.os Bundle putString

Introduction

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

Prototype

public void putString(@Nullable String key, @Nullable String value) 

Source Link

Document

Inserts a String value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:com.nloko.android.syncmypix.facebook.FacebookApi.java

public List<SocialNetworkUser> getUserInfo(String uids, boolean highQuality)
        throws JSONException, ClientProtocolException, IOException {
    if (uids == null) {
        throw new IllegalArgumentException("uids");
    }/*w  w  w  .  java2s  . co  m*/

    /*String[] arr = uids.split(",");
    JSONArray batch_array = new JSONArray();
    for(String uid : arr)
    {
       JSONObject me_friendInfo = new JSONObject();
       try {
    me_friendInfo.put("method", "GET");
    me_friendInfo.put("relative_url", uid);
       } catch (JSONException e) {
     e.printStackTrace();
     Log.e("Error", e.getMessage());
     continue;
       }
               
       JSONObject me_friendPicture = new JSONObject();
       try {
    me_friendPicture.put("method", "GET");
    me_friendPicture.put("relative_url", uid + "/picture?type=large");
       } catch (JSONException e) {
     e.printStackTrace();
     Log.e("Error", e.getMessage());
     continue;
       }
            
            
       batch_array.put(me_friendInfo);
       batch_array.put(me_friendPicture);
    }
            
    Bundle args = new Bundle();
    args.putString("access_token", client.getAccessToken());
    args.putString("batch", batch_array.toString());
            
    String ret = "";
            
    try {
        ret = Util.openUrl("https://graph.facebook.com", "POST", args);
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }*/

    Map<String, String> params = new HashMap<String, String>();
    params.put("uids", uids);
    params.put("fields", "uid,first_name,last_name,name,email,pic_big");
    Bundle bparams = new Bundle();
    bparams.putString("method", "fql.query");
    bparams.putString("query",
            "SELECT uid,first_name,last_name,name,pic_big,email FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())");
    String fqlResponse = client.request(bparams);

    FacebookJSONResponse response = new FacebookJSONResponse(0, fqlResponse);//(FacebookJSONResponse) client.getData ("Users.getInfo", params);
    //Log.d(null, response.data);
    if (response == null || response.isError()) {
        return null;
    }

    JSONArray users = new JSONArray(response.data);

    List<SocialNetworkUser> list = new ArrayList<SocialNetworkUser>();
    Map<String, SocialNetworkUser> userMap = new HashMap<String, SocialNetworkUser>();

    SocialNetworkUser fbUser = null;
    JSONObject user = null;

    for (int i = 0; i < users.length(); i++) {
        user = users.getJSONObject(i);
        fbUser = new SocialNetworkUser();
        fbUser.uid = user.getString("uid");
        fbUser.firstName = user.getString("first_name");
        fbUser.lastName = user.getString("last_name");
        fbUser.name = user.getString("name");
        fbUser.email = user.getString("email");
        fbUser.picUrl = (user.getString("pic_big").equals("null") || user.getString("pic_big") == "") ? null
                : user.getString("pic_big");

        list.add(fbUser);
        userMap.put(user.getString("uid"), fbUser);
    }

    if (highQuality) {
        setHighResPhotos(uids, userMap);
    }

    return list;
}

From source file:com.octade.droid.ilesansfil.IleSansFil.java

@Override
public void onSaveInstanceState(Bundle outState) {
    Date d = new Date();
    outState.putString("DDD", d.toLocaleString());
    super.onSaveInstanceState(outState);
    Log.i(CURRENTMODULE, "onSaveInstanceState Called");
}

From source file:com.akoscz.youtube.YouTubeFragment.java

public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    String json = new Gson().toJson(mPlaylist);
    outState.putString(PLAYLIST_KEY, json);
}

From source file:com.example.helloworldlinked.backend.HelloWorldService.java

public void sendMessage(String textMessage) {
    JSONObject jObj = createTextJSONObject(textMessage);
    Bundle providerData = new Bundle(1);
    providerData.putString(BUNDLE_DATA, jObj.toString());
    Message providerMsg = Message.obtain(null, MSG_TO_HELLOWORLDPROVIDERSERVICE, 0, 0);
    providerMsg.setData(providerData);// w w w  .  j  a  va 2s  . co  m

    sendToProviderService(providerMsg);
}

From source file:com.example.helloworldlinked.backend.HelloWorldService.java

public void sendResetCountMessage() {
    JSONObject jObj = createResetJSONObject();
    Bundle providerData = new Bundle(1);
    providerData.putString(BUNDLE_DATA, jObj.toString());
    Message providerMsg = Message.obtain(null, MSG_TO_HELLOWORLDPROVIDERSERVICE, 0, 0);
    providerMsg.setData(providerData);/*  w ww.ja  v a2s .c o  m*/

    sendToProviderService(providerMsg);
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.activities.MainActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    Log.d(TAG, "onSaveInstance " + hashCode());
    super.onSaveInstanceState(outState);
    outState.putString(KEY_TOOLBAR_TITLE, this.actionBarTitle);
}

From source file:com.appdynamics.demo.gasp.service.RESTIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    Uri action = intent.getData();// w ww .  j a v  a  2 s  .  c  o m
    Bundle extras = intent.getExtras();

    if (extras == null || action == null || !extras.containsKey(EXTRA_RESULT_RECEIVER)) {
        Log.e(TAG, "You did not pass extras or data with the Intent.");
        return;
    }

    int verb = extras.getInt(EXTRA_HTTP_VERB, GET);
    Bundle params = extras.getParcelable(EXTRA_PARAMS);
    Bundle headers = extras.getParcelable(EXTRA_HEADERS);
    ResultReceiver receiver = extras.getParcelable(EXTRA_RESULT_RECEIVER);

    try {
        HttpRequestBase request = null;

        // Get query params from Bundle and build URL
        switch (verb) {
        case GET: {
            request = new HttpGet();
            attachUriWithQuery(request, action, params);
        }
            break;

        case DELETE: {
            request = new HttpDelete();
            attachUriWithQuery(request, action, params);
        }
            break;

        case POST: {
            request = new HttpPost();
            request.setURI(new URI(action.toString()));

            HttpPost postRequest = (HttpPost) request;

            if (params != null) {
                UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramsToList(params));
                postRequest.setEntity(formEntity);
            }
        }
            break;

        case PUT: {
            request = new HttpPut();
            request.setURI(new URI(action.toString()));

            HttpPut putRequest = (HttpPut) request;

            if (params != null) {
                UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramsToList(params));
                putRequest.setEntity(formEntity);
            }
        }
            break;
        }

        // Get Headers from Bundle
        for (BasicNameValuePair header : paramsToList(headers)) {
            request.setHeader(header.getName(), header.getValue());
        }

        if (request != null) {
            HttpClient client = new DefaultHttpClient();

            Log.d(TAG, "Executing request: " + verbToString(verb) + ": " + action.toString());

            HttpResponse response = client.execute(request);

            HttpEntity responseEntity = response.getEntity();
            StatusLine responseStatus = response.getStatusLine();
            int statusCode = responseStatus != null ? responseStatus.getStatusCode() : 0;

            if ((responseEntity != null) && (responseStatus.getStatusCode() == 200)) {
                Bundle resultData = new Bundle();
                resultData.putString(REST_RESULT, EntityUtils.toString(responseEntity));
                receiver.send(statusCode, resultData);
            } else {
                receiver.send(statusCode, null);
            }
        }
    } catch (URISyntaxException e) {
        Log.e(TAG, "URI syntax was incorrect. " + verbToString(verb) + ": " + action.toString(), e);
        receiver.send(0, null);
    } catch (UnsupportedEncodingException e) {
        Log.e(TAG, "A UrlEncodedFormEntity was created with an unsupported encoding.", e);
        receiver.send(0, null);
    } catch (ClientProtocolException e) {
        Log.e(TAG, "There was a problem when sending the request.", e);
        receiver.send(0, null);
    } catch (IOException e) {
        Log.e(TAG, "There was a problem when sending the request.", e);
        receiver.send(0, null);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:most.voip.example.remote_config.MainActivity.java

public void acceptConfig(View view) {
    Intent resultIntent = new Intent();
    Bundle b = new Bundle();
    b.putString("account_data", accountDetailsData);
    b.putString("buddies_data", buddiesDetailsData);

    resultIntent.putExtras(b);//  www. j a v a 2  s . c o  m
    // TODO Add extras or a data URI to this intent as appropriate.
    Log.d(TAG, "Configuration accepted");
    setResult(Activity.RESULT_OK, resultIntent);

    finish();
}

From source file:com.kuacm.expo2013.service.SyncService.java

@Override
protected void onHandleIntent(Intent intent) {
    Log.d(TAG, "onHandleIntent(intent=" + intent.toString() + ")");

    final ResultReceiver receiver = intent.getParcelableExtra(EXTRA_STATUS_RECEIVER);

    if (receiver != null)
        receiver.send(STATUS_RUNNING, Bundle.EMPTY);

    final Context context = this;
    final SharedPreferences prefs = getSharedPreferences(Prefs.IOSCHED_SYNC, Context.MODE_PRIVATE);
    final int localVersion = prefs.getInt(Prefs.LOCAL_VERSION, VERSION_NONE);

    try {/*w w  w .j  a va  2 s. com*/
        // Bulk of sync work, performed by executing several fetches from
        // local and online sources.

        final long startLocal = System.currentTimeMillis();
        final boolean localParse = localVersion < VERSION_CURRENT;
        Log.d(TAG, "found localVersion=" + localVersion + " and VERSION_CURRENT=" + VERSION_CURRENT);
        if (localParse) {
            // Load static local data
            mLocalExecutor.execute(R.xml.blocks, new LocalBlocksHandler());
            mLocalExecutor.execute(R.xml.rooms, new LocalRoomsHandler());
            mLocalExecutor.execute(R.xml.tracks, new LocalTracksHandler());
            mLocalExecutor.execute(R.xml.search_suggest, new LocalSearchSuggestHandler());
            mLocalExecutor.execute(R.xml.sessions, new LocalSessionsHandler());

            // Parse values from local cache first, since spreadsheet copy
            // or network might be down.
            mLocalExecutor.execute(context, "cache-sessions.xml", new RemoteSessionsHandler());
            mLocalExecutor.execute(context, "cache-speakers.xml", new RemoteSpeakersHandler());
            mLocalExecutor.execute(context, "cache-vendors.xml", new RemoteVendorsHandler());

            // Save local parsed version
            prefs.edit().putInt(Prefs.LOCAL_VERSION, VERSION_CURRENT).commit();
        }
        Log.d(TAG, "local sync took " + (System.currentTimeMillis() - startLocal) + "ms");

        // Always hit remote spreadsheet for any updates
        final long startRemote = System.currentTimeMillis();

        mRemoteExecutor.executeGet(WORKSHEETS_URL, new RemoteWorksheetsHandler(mRemoteExecutor));

        Log.d(TAG, "remote sync took " + (System.currentTimeMillis() - startRemote) + "ms");

    } catch (Exception e) {
        Log.e(TAG, "Problem while syncing", e);

        if (receiver != null) {
            // Pass back error to surface listener
            final Bundle bundle = new Bundle();
            bundle.putString(Intent.EXTRA_TEXT, e.toString());
            receiver.send(STATUS_ERROR, bundle);
        }
    }

    // Announce success to any surface listener
    Log.d(TAG, "sync finished");
    if (receiver != null)
        receiver.send(STATUS_FINISHED, Bundle.EMPTY);
}

From source file:com.irccloud.android.fragment.BufferOptionsFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    outState.putInt("bid", bid);
    outState.putInt("cid", cid);
    outState.putString("type", type);
}