Frage

is there any way to return back to latest opened activity and update it I use this code to return back :

super.onBackPressed();

but I want to update it, for example adding new elements dynamicaly I saw the log but I think it doesn't run theoncreate method then how can I update it

War es hilfreich?

Lösung

yes you can achieve this.if you are opening one activity from another activity and updating some elements,and if you need to update that in your previous activity based on the result then open your intent for result..

Example will be

    Intent abc = new Intent(A.this,B.class);
    startActivityForResult(abc,123);

that will open your B.class..while that class completes its operation call

      setResult(RESULT_OK);

and after that in your A.class

override this function

    @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    //super.onActivityResult(requestCode, resultCode, data);
    if(requestCode==123&& resultCode == RESULT_OK)
    //do something...... /*This is the code for updating your A.class */
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top