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.kinvey.sample.signin.GoogleLoginActivity.java

private void finishLogin(String authToken, String password) {
    final Account account = new Account(authToken, UserLogin.ACCOUNT_TYPE);
    Bundle userData = new Bundle();
    userData.putString(UserLogin.LOGIN_TYPE_KEY, PARAM_LOGIN_TYPE_GOOGLE);
    mAccountManager.addAccountExplicitly(account, password, userData);

    final Intent intent = new Intent();
    intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, authToken);
    intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, UserLogin.ACCOUNT_TYPE);
    setResult(RESULT_OK, intent);//www  .j a v a  2  s .com
    finish();
}

From source file:com.umeng.community.example.CommunityApplication.java

@Override
public void onCreate() {
    super.onCreate();
    PlatformConfig.setWeixin("wx96110a1e3af63a39", "c60e3d3ff109a5d17013df272df99199");
    //RENREN?????
    //?/*from   w  w  w.j a va2s  .c  o m*/
    PlatformConfig.setSinaWeibo("275392174", "d96fb6b323c60a42ed9f74bfab1b4f7a");
    PlatformConfig.setQQZone("1104606393", "X4BAsJAVKtkDQ1zQ");
    PushAgent.getInstance(this).setDebugMode(true);
    PushAgent.getInstance(this).setMessageHandler(new UmengMessageHandler() {
        @Override
        public void dealWithNotificationMessage(Context arg0, UMessage msg) {
            // ,????
            super.dealWithNotificationMessage(arg0, msg);
            Log.e("", "### ???");
        }
    });
    PushAgent.getInstance(this).setNotificationClickHandler(new UHandler() {
        @Override
        public void handleMessage(Context context, UMessage uMessage) {
            com.umeng.comm.core.utils.Log.d("notifi", "getting message");
            try {
                JSONObject jsonObject = uMessage.getRaw();
                String feedid = "";
                if (jsonObject != null) {
                    com.umeng.comm.core.utils.Log.d("json", jsonObject.toString());
                    JSONObject extra = uMessage.getRaw().optJSONObject("extra");
                    feedid = extra.optString(Constants.FEED_ID);
                }
                Class myclass = Class.forName(uMessage.activity);
                Intent intent = new Intent(context, myclass);
                Bundle bundle = new Bundle();
                bundle.putString(Constants.FEED_ID, feedid);
                intent.putExtras(bundle);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
            } catch (Exception e) {
                com.umeng.comm.core.utils.Log.d("class", e.getMessage());
            }
        }
    });
}

From source file:com.facebook.notifications.sample.MainActivity.java

/**
 * Mock an example push notification bundle from one of our local example JSON files.
 * @param exampleId The example id of the asset to load
 * @return a bundle with the contents of the specified example id
 */// www .  java 2 s  . c om
@NonNull
private Bundle getBundle(int exampleId) {
    try {
        InputStream inputStream = getAssets().open("example" + exampleId + ".json");

        StringWriter output = new StringWriter();
        IOUtils.copy(inputStream, output, Charset.forName("UTF-8"));

        JSONObject json = new JSONObject(output.toString());

        Bundle bundle = new Bundle();
        bundle.putString("fb_push_card", json.getJSONObject("fb_push_card").toString());
        JSONObject pushPayload = json.optJSONObject("fb_push_payload");
        if (pushPayload != null) {
            bundle.putString("fb_push_payload", pushPayload.toString());
        }

        output.close();
        inputStream.close();

        return bundle;
    } catch (Exception ex) {
        Log.e(LOG_TAG, "Error while getting bundle", ex);
        return new Bundle();
    }
}

From source file:com.gmail.at.faint545.services.DataQueueService.java

@Override
protected void onHandleIntent(Intent intent) {
    String url = intent.getStringExtra("url");
    String api = intent.getStringExtra("api");
    StringBuilder results = new StringBuilder();

    HttpClient client = new DefaultHttpClient();
    HttpPost request = new HttpPost(url);

    ArrayList<NameValuePair> arguments = new ArrayList<NameValuePair>();
    arguments.add(new BasicNameValuePair(SabnzbdConstants.APIKEY, api));
    arguments.add(new BasicNameValuePair(SabnzbdConstants.OUTPUT, SabnzbdConstants.OUTPUT_JSON));
    arguments.add(new BasicNameValuePair(SabnzbdConstants.MODE, SabnzbdConstants.MODE_QUEUE));

    try {/*  w  ww  .ja v a  2s  . c  o m*/
        request.setEntity(new UrlEncodedFormEntity(arguments));
        HttpResponse result = client.execute(request);
        InputStream inStream = result.getEntity().getContent();
        BufferedReader br = new BufferedReader(new InputStreamReader(inStream), 8);
        String line;
        while ((line = br.readLine()) != null) {
            if (line.length() > 0) {
                results.append(line);
            }
        }
        br.close();
        inStream.close();

        Bundle extras = intent.getExtras();
        Messenger messenger = (Messenger) extras.get("messenger");
        Message message = Message.obtain();

        Bundle resultsBundle = new Bundle();
        resultsBundle.putString("results", results.toString());
        message.setData(resultsBundle);

        messenger.send(message);
        stopSelf();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}

From source file:ServiceConsumerActivity.java

public void queryService() {
    if (isBound) {
        Bundle bundle = new Bundle();
        bundle.putString("location", editText.getText().toString().trim());

        Message message = Message.obtain();
        message.replyTo = messengerFromService;
        message.setData(bundle);/*from w w  w  . j av  a  2s. c o  m*/
        try {
            messengerToService.send(message);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    } else {
        textView.setText(R.string.report_appears_here);
        doToast(R.string.service_not_bound);
    }
}

From source file:org.andrico.andrico.UiHandler.java

void executeMethodForMessage(FBMethod m, int messageCode, WriteToProgressHandler progressHandler) {
    HttpResponse response = null;//from   w w w  .j  av a2s  .c  om
    try {
        //TODO: mFACEBOOK = NULL!!!!

        response = mFacebook.execute(m, progressHandler);
    } catch (NullPointerException e) {
        // We don't care if we get a npe. the npe will be handled by the handler.
    } finally {
        Bundle bundle = new Bundle();
        bundle.putString("result", HttpResponseRunnable.httpResponseToString(response));
        Message msg = obtainMessage(messageCode);
        msg.setData(bundle);
        sendMessage(msg);
    }
}

From source file:com.facebook.AuthorizationClient.java

static Bundle newAuthorizationLoggingBundle(String authLoggerId) {
    // We want to log all parameters for all events, to ensure stability of columns across different event types.
    Bundle bundle = new Bundle();
    bundle.putLong(EVENT_PARAM_TIMESTAMP, System.currentTimeMillis());
    bundle.putString(EVENT_PARAM_AUTH_LOGGER_ID, authLoggerId);
    bundle.putString(EVENT_PARAM_METHOD, "");
    bundle.putString(EVENT_PARAM_LOGIN_RESULT, "");
    bundle.putString(EVENT_PARAM_ERROR_MESSAGE, "");
    bundle.putString(EVENT_PARAM_ERROR_CODE, "");
    bundle.putString(EVENT_PARAM_EXTRAS, "");
    return bundle;
}

From source file:org.klnusbaum.udj.auth.Authenticator.java

private Bundle bundleUpAuthToken(Account account, String authToken) {
    final Bundle result = new Bundle();
    result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
    result.putString(AccountManager.KEY_ACCOUNT_TYPE, Constants.ACCOUNT_TYPE);
    result.putString(AccountManager.KEY_AUTHTOKEN, authToken);
    return result;
}

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

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

    String url = HtmlFormUtils.getResponseUrl();

    Bundle args = new Bundle();
    args.putString("link", url);
    args.putString("title", pageTitle);
    args.putString("page", "1");

    // Create new fragment and transaction
    Fragment newFragment = null;
    if (deleteThread) {
        newFragment = new CategoryFragment();
    } else {
        newFragment = ThreadFragment.newInstance();
    }

    FragmentUtils.fragmentTransaction(sourceFragment.getActivity(), newFragment, true, true, args);
}

From source file:com.easy.facebook.android.apicall.FQL.java

public String fqlQuery(String fqlQuery) throws EasyFacebookError {

    Bundle params = new Bundle();
    params.putString("method", "fql.query");
    params.putString("access_token", facebook.getAccessToken());

    params.putString("query", fqlQuery);

    try {//from ww w  .j  a v  a2s  . co m
        return Util.openUrl("https://api.facebook.com/restserver.php", "POST", params);

    } catch (MalformedURLException e) {

        throw new EasyFacebookError(e.toString(), "MalformedURLException");
    } catch (IOException e) {

        throw new EasyFacebookError(e.toString(), "IOException");
    }
}