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:gov.in.bloomington.georeporter.fragments.ReportFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        try {/*from ww  w  .j a  v  a  2  s  .c  o  m*/
            JSONObject s = new JSONObject(savedInstanceState.getString("service"));
            setService(s);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    View v = getLayoutInflater(savedInstanceState).inflate(R.layout.fragment_report, container, false);
    mLocationView = (EditText) v.findViewById(R.id.address_string);

    // Register onClick handlers for all the clickables in the layout
    v.findViewById(R.id.mapChooserButton).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(getActivity(), ChooseLocationActivity.class);
            startActivityForResult(i, CHOOSE_LOCATION_REQUEST);
        }
    });
    v.findViewById(R.id.button_cancel).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), MainActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
        }
    });
    v.findViewById(R.id.button_submit).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            submit(v);
        }
    });
    return v;
}

From source file:com.skubit.android.example.MainActivity.java

public void fetchPurchases(final ListView view) {
    Thread t = new Thread(new Runnable() {

        @Override/*from w  w  w .  ja va2s .c o m*/
        public void run() {
            try {
                Bundle purchases = mService.getPurchases(1, getApplicationContext().getPackageName(), "inapp",
                        null);

                String nextToken = purchases.getString("INAPP_CONTINUATION_TOKEN");
                final ArrayList<String> purchaseData = purchases.getStringArrayList("INAPP_PURCHASE_DATA_LIST");

                final PurchasesFragment purchasesFragment = (PurchasesFragment) mAdapter.getItem(1);

                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            purchasesFragment.displayPurchases(MainActivity.this, view, purchaseData);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                });

                // TODO: validate signatures

            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }
    });
    t.start();
}

From source file:com.chess.genesis.activity.GameListLocalFrag.java

@Override
public boolean handleMessage(final Message msg) {
    switch (msg.what) {
    case DeleteLocalDialog.MSG:
    case RenameGameDialog.MSG:
        gamelist_adapter.update();/*from   w ww.  jav  a2 s .  c o m*/
        break;
    case NewLocalGameDialog.MSG:
        final GameDataDB db = new GameDataDB(act);
        final Bundle bundle = (Bundle) msg.obj;

        final int gametype2 = bundle.getInt("gametype");
        final int gameopp = bundle.getInt("opponent");
        String gamename = bundle.getString("name");
        if (gamename.length() < 1)
            gamename = "untitled";

        final Bundle gamedata = db.newLocalGame(gamename, gametype2, gameopp);
        db.close();

        loadGame(gamedata);
        break;
    }
    return true;
}

From source file:com.spoiledmilk.ibikecph.IssuesActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_issues);
    spinner = (Spinner) findViewById(R.id.spinner);
    Bundle data = getIntent().getExtras();
    turns = data.getStringArrayList("turns");
    startLoc = data.getString("startLoc");
    endLoc = data.getString("endLoc");
    startName = data.getString("startName");
    endName = data.getString("endName");
    IssuesAdapter dataAdapter = new IssuesAdapter(this, turns, R.layout.list_row_issues,
            R.layout.spinner_layout);/*from   w w  w . j a  v a  2  s  . co  m*/
    spinner.setAdapter(dataAdapter);
    textTitle = (TextView) findViewById(R.id.textTitle);
    textOption1 = (TextView) findViewById(R.id.textOption1);
    textOption2 = (TextView) findViewById(R.id.textOption2);
    textOption3 = (TextView) findViewById(R.id.textOption3);
    textOption4 = (TextView) findViewById(R.id.textOption4);
    textOption5 = (TextView) findViewById(R.id.textOption5);
    textOption6 = (TextView) findViewById(R.id.textOption6);
    textComment1 = (EditText) findViewById(R.id.textComment1);
    textComment2 = (EditText) findViewById(R.id.textComment2);
    textComment3 = (EditText) findViewById(R.id.textComment3);
    textComment4 = (EditText) findViewById(R.id.textComment4);
    textComment5 = (EditText) findViewById(R.id.textComment5);
    textComment6 = (EditText) findViewById(R.id.textComment6);
    imgRadio1 = (ImageView) findViewById(R.id.imgRadio1);
    imgRadio2 = (ImageView) findViewById(R.id.imgRadio2);
    imgRadio3 = (ImageView) findViewById(R.id.imgRadio3);
    imgRadio4 = (ImageView) findViewById(R.id.imgRadio4);
    imgRadio5 = (ImageView) findViewById(R.id.imgRadio5);
    imgRadio6 = (ImageView) findViewById(R.id.imgRadio6);
    btnSend = (TexturedButton) findViewById(R.id.btnSend);
    btnSend.setTextureResource(R.drawable.btn_pattern_repeteable);
    btnSend.setBackgroundResource(R.drawable.btn_blue_selector);
    btnSend.setTextColor(Color.WHITE);
    IbikeApplication.getTracker().sendEvent("Report", "Start", "", (long) 0);
    deselectAll();
}

From source file:com.arthackday.killerapp.GCMIntentService.java

@Override
protected void onMessage(Context ctxt, Intent message) {
    Log.i("REMOVE BEFORE COMMIT", "blahhhhhhh GCMessage");
    Bundle extras = message.getExtras();

    /*/*  w ww . ja  v a  2 s.c  o m*/
     * TO DO! CHANGE WHAT THE MESSAGES DO!!
     */

    for (String key : extras.keySet()) {
        Log.i(getClass().getSimpleName(), String.format("onMessage: %s=%s", key, extras.getString(key)));

        if (key.equals(KillerConstants.EXTRA_KEY_AUDIO)) {
            Log.i("REMOVE BEFORE COMMIT", "blahhhhhhh pushAudio");
            Intent i = new Intent();
            Log.i("REMOVE BEFORE COMMIT", extras.getString(key));

            Bundle bundle = new Bundle();
            //Add your data to bundle
            bundle.putString(KillerConstants.EXTRA_KEY_AUDIO, extras.getString(key));
            //Add the bundle to the intent
            i.putExtras(bundle);
            i.setClassName("com.arthackday.killerapp", "com.arthackday.killerapp.PushAudio");
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(i);
        }

        if (key.equals(KillerConstants.EXTRA_KEY_PUSHCALL)) {
            Log.i("REMOVE BEFORE COMMIT", "blahhhhhhh callnumber");
            String number = extras.getString(KillerConstants.EXTRA_KEY_PUSHCALL);
            String uri = "tel:" + number.trim();
            Intent intent = new Intent(Intent.ACTION_CALL);
            intent.setData(Uri.parse(uri));
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        }
    }
}

From source file:net.reichholf.dreamdroid.activities.DreamDroidShareActivity.java

@SuppressWarnings("deprecation")
private void playOnDream(Profile p) {
    String url = null;// w  ww  . j a  va 2 s  .  co  m
    Intent i = getIntent();
    Bundle extras = i.getExtras();
    mShc = SimpleHttpClient.getInstance(p);
    if (Intent.ACTION_SEND.equals(i.getAction()))
        url = extras.getString(Intent.EXTRA_TEXT);
    else if (Intent.ACTION_VIEW.equals(i.getAction()))
        url = i.getDataString();

    if (url != null) {
        Log.i(LOG_TAG, url);
        Log.i(LOG_TAG, p.getHost());

        String time = DateFormat.getDateFormat(this).format(new Date());
        String title = getString(R.string.sent_from_dreamdroid, time);
        if (extras != null) {
            // semperVidLinks sends "artist" and "song" attributes for the
            // youtube video titles
            String song = extras.getString("song");
            if (song != null) {
                String artist = extras.getString("artist");
                if (artist != null)
                    title = artist + " - " + song;
            } else {
                String tmp = extras.getString("title");
                if (tmp != null)
                    title = tmp;
            }
        }
        mTitle = new String(title);

        url = URLEncoder.encode(url).replace("+", "%20");
        title = URLEncoder.encode(title).replace("+", "%20");

        String ref = "4097:0:1:0:0:0:0:0:0:0:" + url + ":" + title;
        Log.i(LOG_TAG, ref);
        ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("file", ref));
        execSimpleResultTask(params);
    } else {
        finish();
    }
}

From source file:gov.whitehouse.ui.fragments.app.ArticleViewerFragment.java

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

    Bundle args = getArguments();

    mPageInfo = new JSONObject();
    try {//w  ww . j  a  v  a2 s .  c om
        mPageInfo.put("title", args.getString("title"));
        final SimpleDateFormat date = new SimpleDateFormat("MMM d, yyyy h:mm a");
        final DateFormat parse = DateFormat.getDateTimeInstance();
        mPageInfo.put("date", date.format(parse.parse(args.getString("date"))));
        mPageInfo.put("creator", args.getString("creator"));
        mPageInfo.put("description", args.getString("description"));
        mPageInfo.put("url", args.getString("url"));
        mWebView.loadUrl(PAGE_TEMPLATE_URL);
    } catch (JSONException e) {
        Log.e(TAG, "error creating JSON object for post", e);
    } catch (ParseException e) {
    }

    mArticleType = args.getInt(ARG_FEED_TYPE, ARTICLE_TYPE_FEED);
    mUpTitle = args.getString(ARG_UP_TITLE);
    if (!((BaseActivity) getSherlockActivity()).isMultipaned()) {
        switch (mArticleType) {
        case ARTICLE_TYPE_FEED:
            getSherlockActivity().getSupportActionBar().setTitle(mUpTitle.toUpperCase());
            break;
        case ARTICLE_TYPE_FAVORITES:
            getSherlockActivity().getSupportActionBar().setTitle(R.string.favorites);
            break;
        }
    }

    final String json = args.getString(ARG_ITEM_JSON);
    if (json != null) {
        mFeedItem = GsonUtils.fromJson(json, FeedItem.class);
    }

    mFavorited = FavoritesUtils.isFavorited(getSherlockActivity(), mFeedItem);
}

From source file:com.jiee.smartplug.services.MyGcmListenerService.java

/**
 * Called when message is received./* ww  w  . ja  v  a2  s  . com*/
 *
 * @param from SenderID of the sender.
 * @param data Data bundle containing message data as key/value pairs.
 *             For Set of keys use data.keySet().
 */
// [START receive_message]
@Override
public void onMessageReceived(String from, Bundle data) {

    if (http == null)
        http = new HTTPHelper(this);

    System.out.println(data);
    MySQLHelper sql = HTTPHelper.getDB(this);
    String message = data.getString("message");
    String showFlag = data.getString("showFlag");
    String getDataFlag = data.getString("getDataFlag");
    String getDeviceFlag = data.getString("getDeviceFlag");
    String getAlarmFlag = data.getString("getAlarmFlag");
    String devId = data.getString("devid");
    Log.d(TAG, "From: " + from + " msg: " + message + " devid:" + devId + " (flag=" + showFlag + ", data="
            + getDataFlag + ", dev=" + getDeviceFlag + ", alarm=" + getAlarmFlag + ")");

    if (getDataFlag.equals("true")) {
        String param = "devget?token=" + Miscellaneous.getToken(getApplicationContext()) + "&hl="
                + Locale.getDefault().getLanguage() + "&res=0&devid=" + devId;
        try {
            if (devId != null && !devId.isEmpty() && !devId.equals("null")) {
                http.getDeviceStatus(param, devId, getApplicationContext(), false);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    if (getAlarmFlag.equals("true")) {
        try {
            if (devId != null && !devId.isEmpty() && !devId.equals("null")) {
                http.updateAlarms(devId);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    Intent intent = new Intent("gcm_notification");
    intent.putExtra("getDeviceFlag", getDeviceFlag);
    intent.putExtra("getDataFlag", getDataFlag);
    intent.putExtra("getAlarmFlag", getAlarmFlag);
    intent.putExtra("message", message);
    sendBroadcast(intent);

    if (from.startsWith("/topics/")) {
        // message received from some topic.
    } else {
        // normal downstream message.
    }

    // [START_EXCLUDE]
    /**
     * Production applications would usually process the message here.
     * Eg: - Syncing with server.
     *     - Store message in local database.
     *     - Update UI.
     */

    /**
     * In some cases it may be useful to show a notification indicating to the user
     * that a message was received.
     */
    if (showFlag != null && showFlag.equals("true")) {
        sendNotification(message);
    }
    // [END_EXCLUDE]
}

From source file:fr.cph.chicago.core.activity.BusBoundActivity.java

@Override
public final void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    App.checkBusData(this);
    if (!this.isFinishing()) {
        setContentView(R.layout.activity_bus_bound);
        ButterKnife.bind(this);

        if (busRouteId == null || busRouteName == null || bound == null || boundTitle == null) {
            final Bundle extras = getIntent().getExtras();
            busRouteId = extras.getString(bundleBusRouteId);
            busRouteName = extras.getString(bundleBusRouteName);
            bound = extras.getString(bundleBusBound);
            boundTitle = extras.getString(bundleBusBoundTitle);
        }//w ww  .jav a 2 s  . co m
        busBoundAdapter = new BusBoundAdapter();
        setListAdapter(busBoundAdapter);
        getListView().setOnItemClickListener((adapterView, view, position, id) -> {
            final BusStop busStop = (BusStop) busBoundAdapter.getItem(position);
            final Intent intent = new Intent(getApplicationContext(), BusActivity.class);

            final Bundle extras = new Bundle();
            extras.putInt(bundleBusStopId, busStop.getId());
            extras.putString(bundleBusStopName, busStop.getName());
            extras.putString(bundleBusRouteId, busRouteId);
            extras.putString(bundleBusRouteName, busRouteName);
            extras.putString(bundleBusBound, bound);
            extras.putString(bundleBusBoundTitle, boundTitle);
            extras.putDouble(bundleBusLatitude, busStop.getPosition().getLatitude());
            extras.putDouble(bundleBusLongitude, busStop.getPosition().getLongitude());

            intent.putExtras(extras);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        });

        filter.addTextChangedListener(new TextWatcher() {
            private List<BusStop> busStopsFiltered;

            @Override
            public void beforeTextChanged(final CharSequence s, final int start, final int count,
                    final int after) {
                busStopsFiltered = new ArrayList<>();
            }

            @Override
            public void onTextChanged(final CharSequence s, final int start, final int before,
                    final int count) {
                if (busStops != null) {
                    Stream.of(busStops).filter(busStop -> StringUtils.containsIgnoreCase(busStop.getName(), s))
                            .forEach(busStopsFiltered::add);
                }
            }

            @Override
            public void afterTextChanged(final Editable s) {
                busBoundAdapter.update(busStopsFiltered);
                busBoundAdapter.notifyDataSetChanged();
            }
        });

        Util.setWindowsColor(this, toolbar, TrainLine.NA);
        toolbar.setTitle(busRouteId + " - " + boundTitle);

        toolbar.setNavigationIcon(arrowBackWhite);
        toolbar.setOnClickListener(v -> finish());

        ObservableUtil.createBusStopBoundObservable(getApplicationContext(), busRouteId, bound)
                .subscribe(onNext -> {
                    busStops = onNext;
                    busBoundAdapter.update(onNext);
                    busBoundAdapter.notifyDataSetChanged();
                }, onError -> {
                    Log.e(TAG, onError.getMessage(), onError);
                    Util.showOopsSomethingWentWrong(getListView());
                });

        Util.trackAction(this, R.string.analytics_category_req, R.string.analytics_action_get_bus,
                BUSES_STOP_URL, 0);

        // Preventing keyboard from moving background when showing up
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    }
}

From source file:net.reichholf.dreamdroid.activities.ShareActivity.java

@SuppressWarnings("deprecation")
private void playOnDream(Profile p) {
    String url = null;/*from ww w.  j av  a  2 s  . c  o  m*/
    Intent i = getIntent();
    Bundle extras = i.getExtras();
    mShc = SimpleHttpClient.getInstance(p);
    if (Intent.ACTION_SEND.equals(i.getAction()))
        url = extras.getString(Intent.EXTRA_TEXT);
    else if (Intent.ACTION_VIEW.equals(i.getAction()))
        url = i.getDataString();

    if (url != null) {
        Log.i(LOG_TAG, url);
        Log.i(LOG_TAG, p.getHost());

        String time = DateFormat.getDateFormat(this).format(new Date());
        String title = getString(R.string.sent_from_dreamdroid, time);
        if (extras != null) {
            // semperVidLinks sends "artist" and "song" attributes for the
            // youtube video titles
            String song = extras.getString("song");
            if (song != null) {
                String artist = extras.getString("artist");
                if (artist != null)
                    title = artist + " - " + song;
            } else {
                String tmp = extras.getString("title");
                if (tmp != null)
                    title = tmp;
            }
        }
        mTitle = title;

        url = URLEncoder.encode(url).replace("+", "%20");
        title = URLEncoder.encode(title).replace("+", "%20");

        String ref = "4097:0:1:0:0:0:0:0:0:0:" + url + ":" + title;
        Log.i(LOG_TAG, ref);
        ArrayList<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("file", ref));
        execSimpleResultTask(params);
    } else {
        finish();
    }
}