Difference between revisions of "Android start activity for result"

From John Freier
Jump to: navigation, search
(Created page with '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, startActivityForRes…')
 
(No difference)

Latest revision as of 07:56, 7 July 2011

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();