=+ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_second); //---get the data passed in using getStringExtra()--- Toast.makeText(this,getIntent().getStringExtra(str1),
Question:
=+ @Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
//---get the data passed in using getStringExtra()---
Toast.makeText(this,getIntent().getStringExtra("str1"), Toast.LENGTH_SHORT).show();
//---get the data passed in using getIntExtra()---
Toast.makeText(this,Integer.toString(
getIntent().getIntExtra("age1", 0)), Toast.LENGTH_SHORT).show();
//---get the Bundle object passed in---
Bundle bundle = getIntent().getExtras();
//---get the data using the getString()---
Toast.makeText(this, bundle.getString("str2"), Toast.LENGTH_SHORT).show();
//---get the data using the getInt() method---
Toast.makeText(this,Integer.toString(bundle.getInt("age2")), Toast.LENGTH_SHORT).show();
}
Step by Step Answer:
Beginning Android Programming With Android Studio
ISBN: 9781118707425
4th Edition
Authors: Wei Meng Lee, Jerome F DiMarzio