Posts

Showing posts with the label bundle

Bundle containsKey() but returns null on getString()

Back to blogging after a long time, and this time its quite a lame one which I usually wouldn't want to blog about, but I did spend close to an hour trying to figure out what I was doing wrong. I just started a small android application and was trying to send a paramter from one Activity to another. Now, after a bit of searching around, I found out that I needed to create an Intent Bundle and put the parameter in it, and the new Activity which gets started will be able to fetch it from the same Bundle using the key that was provided while inserting data into the Bundle . So, I had something like this in the first activity: Intent intent = new Intent(FirstActivity.this, SecondActivity.class); EditText nameText = (EditText) findViewById(R.id.query_textbox); intent.putExtra("queryKey", nameText.getText()); startActivity(intent); and something like this in the second activity: Bundle extras = getIntent().getExtras(); String query = extras.getString("queryKey");...