Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To get result form an activity (child) you do as follow :</p> <p>In the parent activity</p> <pre><code>startActivityForResult(myIntent, 1); </code></pre> <p>global vars of your parent activity</p> <pre><code>boolean backFromChild = false; String aString; </code></pre> <p>then still in the parent activity</p> <pre><code>@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1) { if (resultCode == RESULT_OK) { // code for result aString = getIntent().getExtras().getString("aString"); backFromChild = true; } if (resultCode == RESULT_CANCELED) { // Write your code on no result return } } } </code></pre> <p>in your child you do somewhere something like that</p> <pre><code>Intent returnIntent = new Intent(); //example of sending back a string to the parent. returnIntent.putExtra("aString", aString); setResult(RESULT_OK, returnIntent); finish(); </code></pre> <p>The thing is that <code>onResume</code> of your parent activity will be called when returning from your child. In there you have to perform the update, in your case it is to update the information of the edited text :</p> <pre><code>@Override public void onResume(){ super.onResume(); if (backFromChild){ backFromChild = false; //do something with aString here Toast.makeText(this, aString, Toast.LENGTH_SHORT).show(); } } </code></pre> <p>Basically, in the <code>onActivityResult</code> I get the info back from the intent of the child. Then in <code>onResume</code> I use this info.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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