Its a common operation in Android application to launch new activity all the time. There are times when you want to receive the result from new activity started. For example in one of my recent projects I have to launch settings activity ( SettingsActivity ) to set the mode of application and when this activity is closed it should return the selected mode to the caller activity ( MainActivity ). How child Activity returns result Activity class has a method setResult which sets the result code to be returned to parent activity. Another overload of setResult allows you to pass Intent also for any extra data to be sent. In my SettingsActivity I have code like this if (settingsSavedByUser()){ Intent i=new Intent(); i.putExtra("mode","selectedApplicationMode"); setResult(RESULT_OK,i); //RESULT_OK and Intent(i) will be returned to parent }else{ setResult(RESULT_CANCELLED); //RESULT_CANCELLED will be returned to p...
I document random stuff on this Blog. It can be a piece of code , my personal experience, a fun fact or anything else.