Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can pass around objects via an intent. The extras function of an intent can store a bundle and send it to specified activities, however they cannot be called at any time (like from a later activity without being explicitly sent). If this is a one time pass to a different activity, the you'd probably want to use that.</p> <p><a href="http://developer.android.com/reference/android/content/Intent.html#putExtras%28android.content.Intent%29" rel="nofollow">http://developer.android.com/reference/android/content/Intent.html#putExtras%28android.content.Intent%29</a></p> <p>Here is an example from a test app I made a while back:</p> <pre><code>public void onClick(View v) { switch(v.getId()) { //this references the unique ID of the view that was clicked case R.id.Button01: //this is what happens when the Button in the XML with android:id="@+id/Button01" is clicked Intent nameGreet = new Intent(this, MainMenu.class);//creates Intent which will send the EditText input String theName = firstName.getText().toString();// creates a new string named "theName" which is the text from an EditText called "firstName" nameGreet.putExtra("helloName", theName);//puts the input from EditText into the Intent, this is a key/value pair this.startActivity(nameGreet);//setting off the Intent break; </code></pre> <p>Then you catch it like so:</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.main_menu); String personsname = this.getIntent().getStringExtra("helloName"); welcome = (TextView)this.findViewById(R.id.TextView01); welcome.setText(personsname); </code></pre> <p>Hope this helps.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload