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:org.roman.findme.MyGcmListenerService.java

/**
 * Called when message is received.//from  w w w  .j av  a  2  s.c o  m
 *
 * @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) {
    sharedPreferences = getSharedPreferences(RegistrationIntentService.APP_PREFERENCES, Context.MODE_PRIVATE);
    myToken = sharedPreferences.getString("my_token", null);
    mContext = this;

    String message = data.getString("message");
    assert message != null;

    Gson gson = new Gson();
    String[] response = gson.fromJson(message, String[].class);

    message = response[0];
    senderToken = response[1].replaceAll("\\s+", "");

    Log.d(TAG, data.toString());
    Log.d(TAG, message);
    Log.d(TAG, senderToken);

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

    if (message.equals("c")) {
        Intent locationService = new Intent(this, LocationService.class);
        startService(locationService);
    } else {
        sendNotification(message);
    }

}

From source file:com.cssweb.android.quote.QuoteDetail.java

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

    HandlerThread mHandlerThread = new HandlerThread("CSSWEB_THREAD");
    mHandlerThread.start();/*from w w w  . j  a va 2s  .c  o  m*/
    mHandler = new MessageHandler(mHandlerThread.getLooper());

    setContentView(R.layout.zr_quote_price);
    initTitle(R.drawable.njzq_title_left_back, 0, "");
    Bundle bundle = getIntent().getExtras();
    this.exchange = bundle.getString("exchange");
    this.stockcode = bundle.getString("stockcode");
    this.stocktype = bundle.getString("stocktype");
    this.type = NameRule.getSecurityType(exchange, stockcode);
    if (stocktype == null || stocktype.equals(""))
        stocktype = NameRule.getStockType(type);
    table_1 = (TableLayout) findViewById(R.id.zr_rt_tableview_1);
    setTitleText(getResources().getString(R.string.cjmx_title));
    customScrollView = (CustomScrollView) findViewById(R.id.zr_htable_vscroll);
    customScrollView.setOnTouchListener(this);
    customScrollView.setGestureDetector(gestureDetector);
}

From source file:com.pansapiens.occyd.MapResults.java

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

    // receive search results from calling Activity, 
    // as a raw json string
    Bundle incoming_data = getIntent().getExtras();
    String json_txt = null;//from  w w  w  .  j a  va  2  s.c  om
    ArrayList<Post> post_results = new ArrayList();
    if (incoming_data != null) {
        json_txt = incoming_data.getString("json");
        try {
            post_results = JSONdecoder.json2postArray(json_txt);
        } catch (JSONException e) {
            Toast.makeText(MapResults.this, "FAIL: Malformed response from server.", Toast.LENGTH_LONG).show();
        }
    }

    setContentView(R.layout.mapview);
    map = (MapView) findViewById(R.id.map);

    // zoom controls are placed in their own 'sub-layout' called
    // "@+id/zoom" in the mapview.xml layout.
    // this ensures they are correctly positioned, don't scroll offscreen
    // and don't prevent touch scrolling of the map when visible 
    LinearLayout zoomView = (LinearLayout) findViewById(R.id.zoom);
    zoomView.addView(map.getZoomControls());

    // (straight out of the MapViewCompassDemo.java API Demos)
    // put a dot on our current location once we have a fix
    mMyLocationOverlay = new MyLocationOverlay(this, map);
    mMyLocationOverlay.runOnFirstFix(new Runnable() {
        public void run() {
            map.getController().animateTo(mMyLocationOverlay.getMyLocation());
        }
    });
    map.getOverlays().add(mMyLocationOverlay);
    map.getController().setZoom(17);

    locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
    LocationUpdater locupdater = new LocationUpdater(locationManager, this);
    locupdater.startUpdating();

    // add markers for search results
    // marker from: http://commons.wikimedia.org/wiki/File:Map_symbol_location_02.png
    Drawable marker = getResources().getDrawable(R.drawable.marker);

    marker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight());

    map.getOverlays().add(new MapResultsOverlay(marker, post_results));
    //map.getOverlays().add(new MapResultsOverlay(marker)); // dummy testing constructor ....
}

From source file:org.planetmono.dcuploader.SignOnGallog.java

public Runnable getMethodSignOn(final Application app, final Bundle b, final Handler resultHandler) {
    return new Runnable() {
        public void run() {
            String id, password;/* w w  w. j a  v  a2s .  c om*/

            id = b.getString("id");
            password = b.getString("password");

            Message m = resultHandler.obtainMessage();
            Bundle bm = m.getData();

            Log.d(Application.TAG, "logging in...");

            HttpPost post = new HttpPost(SIGNON_URL);
            List<NameValuePair> vlist = new ArrayList<NameValuePair>();
            vlist.add(new BasicNameValuePair("user_id", id));
            vlist.add(new BasicNameValuePair("password", password));
            vlist.add(new BasicNameValuePair("x", "0"));
            vlist.add(new BasicNameValuePair("y", "0"));
            vlist.add(new BasicNameValuePair("s_url", "about:blank"));
            try {
                post.setEntity(new UrlEncodedFormEntity(vlist));
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }

            post.setHeader("Origin", SIGNON_BASE_URL);
            post.setHeader("Referer", SIGNON_PAGE_URL);

            HttpResponse response = null;
            try {
                response = app.sendPostRequest(post);
            } catch (Exception e) {
                e.printStackTrace();

                bm.putBoolean("result", false);
                bm.putString("resultString", " ");
                resultHandler.sendMessage(m);
                return;
            }

            HttpEntity entity = response.getEntity();
            BufferedReader r;
            try {
                r = new BufferedReader(new InputStreamReader(entity.getContent(), "UTF-8"));

                while (true) {
                    String line = r.readLine();
                    if (line == null)
                        break;

                    if (line.contains(" ")
                            || line.contains("?? ? ")) {
                        bm.putBoolean("result", false);
                        bm.putString("resultString", "? ");
                        resultHandler.sendMessage(m);
                        entity.consumeContent();
                        return;
                    } else if (line.contains("about:blank")) {
                        /* successful */
                        bm.putBoolean("result", true);
                        bm.putInt("method", getMethodId());
                        resultHandler.sendMessage(m);
                        entity.consumeContent();
                        return;
                    }
                }
            } catch (Exception e) {
                bm.putBoolean("result", false);
                bm.putString("resultString", " ");
                resultHandler.sendMessage(m);

                try {
                    entity.consumeContent();
                } catch (IOException e1) {
                }

                return;
            }

            try {
                entity.consumeContent();
            } catch (IOException e) {
            }

            /* abnormal status. */
            bm.putBoolean("result", false);
            bm.putString("resultString", "   .");
            resultHandler.sendMessage(m);
        }
    };
}

From source file:com.loadsensing.app.SingleSensorActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.single_sensor);

    // Get Intent parameters

    Bundle extras = null;
    if (savedInstanceState == null) {
        extras = getIntent().getExtras();
        if (extras == null) {
            SensorSelected = null;/*  w  w w . j  a v  a  2 s.c  o  m*/
        } else {
            SensorSelected = extras.getString("idsensorselected");
            Log.d(DEB_TAG, "Xarxa que hem triat anteriorment: " + SensorSelected);
        }
    }

    SharedPreferences settings = getSharedPreferences("LoadSensingApp", Context.MODE_PRIVATE);
    String address = SERVER_HOST + "?sensor=" + SensorSelected + "&session="
            + settings.getString("session", "");
    Log.d(DEB_TAG, "Requesting to " + address);

    try {
        String jsonString = JsonClient.connectString(address);

        // Convertim la resposta string a un JSONArray
        JSONArray llistaSensorsArray = new JSONArray(jsonString);
        JSONObject sensorJSON = llistaSensorsArray.getJSONObject(0);

        TextView idsensor = (TextView) findViewById(R.id.sensor);
        TextView nomsensor = (TextView) findViewById(R.id.sensorname);
        TextView serialnumber = (TextView) findViewById(R.id.serialnumber);
        TextView mesura = (TextView) findViewById(R.id.measure);
        TextView unitatmesura = (TextView) findViewById(R.id.measureunit);
        TextView maxload = (TextView) findViewById(R.id.maxload);
        TextView MaxLoadUnit = (TextView) findViewById(R.id.maxloadunit);
        TextView Sensivity = (TextView) findViewById(R.id.sensitivity);
        TextView SensivityUnit = (TextView) findViewById(R.id.sensitivityunit);
        TextView offset = (TextView) findViewById(R.id.offset);
        TextView offsetUnit = (TextView) findViewById(R.id.offsetunit);
        TextView AlarmAt = (TextView) findViewById(R.id.alarmat);
        TextView AlarmAtUnit = (TextView) findViewById(R.id.alarmAtunit);
        TextView LastTare = (TextView) findViewById(R.id.lasttare);
        TextView canal = (TextView) findViewById(R.id.canal);
        TextView tipus = (TextView) findViewById(R.id.tipus);
        TextView Descripcio = (TextView) findViewById(R.id.descripcio);
        TextView Poblacio = (TextView) findViewById(R.id.poblacio);
        TextView Nom = (TextView) findViewById(R.id.nom);

        idsensor.setText(sensorJSON.getString("sensor"));
        nomsensor.setText(sensorJSON.getString("sensorName"));
        serialnumber.setText(sensorJSON.getString("serialNumber"));
        mesura.setText(sensorJSON.getString("measure"));
        unitatmesura.setText(sensorJSON.getString("measureUnit"));
        maxload.setText(sensorJSON.getString("MaxLoad"));
        MaxLoadUnit.setText(sensorJSON.getString("MaxLoadUnit"));
        Sensivity.setText(sensorJSON.getString("Sensivity"));
        SensivityUnit.setText(sensorJSON.getString("SensivityUnit"));
        offset.setText(sensorJSON.getString("offset"));
        offsetUnit.setText(sensorJSON.getString("offsetUnit"));
        AlarmAt.setText(sensorJSON.getString("AlarmAt"));
        AlarmAtUnit.setText(sensorJSON.getString("AlarmAtUnit"));
        LastTare.setText(sensorJSON.getString("LastTare"));
        canal.setText(sensorJSON.getString("canal"));
        tipus.setText(sensorJSON.getString("tipus"));
        Descripcio.setText(sensorJSON.getString("Descripcio"));
        Poblacio.setText(sensorJSON.getString("Poblacio"));
        Nom.setText(sensorJSON.getString("Nom"));

    } catch (Exception ex) {
        Log.d(DEB_TAG, "Exception: " + ex.getMessage());
    }
}

From source file:mp.paschalis.SendMessageActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_send_message);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    app = (App) getApplication();/*from  w  ww .  j  a  va2 s. c  om*/

    editTextMessage = (EditText) findViewById(R.id.editTextMessage);

    buttonSendMessage = (Button) findViewById(R.id.buttonSendMessage);
    progressBarSendMessage = (ProgressBar) findViewById(R.id.progressBarSendMessage);

    // Get arguments, to determine who opened this activity
    final Bundle extras = getIntent().getExtras();

    try {
        destUser = extras.getString(App.ExtrasForSendMessage_DestinationUser);
    } catch (Exception e) {
        this.finish();
    }

    editTextMessage.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            if (editTextMessage.getText().length() >= 3)
                buttonSendMessage.setEnabled(true);
            else
                buttonSendMessage.setEnabled(false);
        }
    });

    buttonSendMessage.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            new AsyncTaskSendMessage().execute(destUser);

        }
    });

}

From source file:com.starwood.anglerslong.LicenseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.license);/*from ww  w . j a  va  2s.  com*/

    Bundle bundle = this.getIntent().getExtras();
    getSupportActionBar().setTitle(bundle.getString("abtitle"));
    //        getSupportActionBar().setSubtitle(bundle.getString("subtitle"));
    //        getSupportActionBar().setDisplayHomeAsUpEnabled(true);    // <- This puts the back arrow in actionbar

    if (bundle.containsKey("isArrayEmpty"))
        isArrayEmpty = bundle.getBoolean("isArrayEmpty");

    populateTabs(false); // Populate the tabs within the clicked tab.

}

From source file:com.game.simple.Game3.java

public static void inviteFB() {

    self.runOnUiThread(new Runnable() {
        public void run() {
            if (Session.getActiveSession() != null && Session.getActiveSession().isOpened()) {
                ///
                Bundle params = new Bundle();
                params.putString("message", "Let's play iCasino !");
                params.putString("data", "{\"badge_of_awesomeness\":\"1\"," + "\"social_karma\":\"5\"}");
                WebDialog requestsDialog = (new WebDialog.RequestsDialogBuilder(self,
                        Session.getActiveSession(), params)).setOnCompleteListener(new OnCompleteListener() {

                            @Override
                            public void onComplete(Bundle values, FacebookException error) {
                                if (error != null) {
                                    if (error instanceof FacebookOperationCanceledException) {
                                        Toast.makeText(self.getApplicationContext(), "Hy m?i!",
                                                Toast.LENGTH_SHORT).show();
                                    } else {
                                        Toast.makeText(self.getApplicationContext(), "Hy b?",
                                                Toast.LENGTH_SHORT).show();
                                    }/*w w w  .ja  va2  s  . c o  m*/
                                } else {
                                    final String requestId = values.getString("request");
                                    if (requestId != null) {
                                        Toast.makeText(self.getApplicationContext(), "? m?i !",
                                                Toast.LENGTH_SHORT).show();
                                    } else {
                                        Toast.makeText(self.getApplicationContext(), "Hy !",
                                                Toast.LENGTH_SHORT).show();
                                    }
                                }
                            }

                        }).build();
                requestsDialog.show();
            }

            else {

                loginFB();
            }
        }
    });
}

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

@Override
public void onRestoreInstanceState(final Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    try {/*from  w  w  w  . j ava 2 s . co  m*/
        if (savedInstanceState.containsKey("commitsJson")) {
            mCommitsJSON = new JSONArray(savedInstanceState.getString("commitsJson"));
        }
    } catch (final Exception e) {
        e.printStackTrace();
        return;
    }
    if (mCommitsJSON != null) {
        mCommitListAdapter = new CommitListAdapter(this, mCommitsJSON);
    }
}

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

@Override
public boolean onContextItemSelected(final MenuItem item) {
    if (!act.lastContextMenu.equals(getBTag()))
        return super.onContextItemSelected(item);

    switch (item.getItemId()) {
    case R.id.new_game:
    case R.id.import_game:
        return onOptionsItemSelected(item);
    }/*from   ww  w.  jav a 2  s. co  m*/

    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    final Bundle bundle = (Bundle) gamelist_adapter.getItem((int) info.id);

    switch (item.getItemId()) {
    case R.id.delete_game:
        new DeleteLocalDialog(act, handle, Integer.parseInt(bundle.getString("id"))).show();
        break;
    case R.id.rename_game:
        new RenameGameDialog(act, handle, Integer.parseInt(bundle.getString("id")), bundle.getString("name"))
                .show();
        break;
    case R.id.share_game:
        sendGame(bundle);
        break;
    default:
        return super.onContextItemSelected(item);
    }
    return true;
}