Android start activity for result

From John Freier
Jump to: navigation, search

Start Activity For Result

This starts an activity and get a result from it, for example you want to create a custom input form.

You start the activity with, startActivityForResult()

Intent intent = new Intent();
intent.setClass(getApplicationContext(), ItemActivity.class);
startActivityForResult(intent, 1);


You finish the next activity with, it will take you back to the last activity that was used to open it.

Intent intent=new Intent();
intent.putExtra("variable", "mom");
setResult(RESULT_OK, intent);
       
finish();