I am creating an application in which I want to have Alarm like functionality. I mean on my parent view there will be a button which on click will show a view where user can take action, then when he clicks on save then the data from the child view is passed to parent view and is shown in listview on parent view. The same functionality how we add new alarm in Android. I am new to android development, so please can somebody point me to some article explaining similar functionality or help me with some code?
Thanks
Ashwani
When switching to the child activity, you need to use
startActivityForResultmethod (instead ofstartActivity) of your parent activity. This way the parent will be notified when the subsequent activity is finished and returned.Your child activity should be finished by explicitly setting the result of it (whether it is important:
RESULT_OK/RESULT_CANCELED), and adding the necessary data to the intent’s extras (intent.putExtra(name, value);). This will be done in theOnClickListenerof your save button.To get the notification of the return of child activity, you have to override the
onActivityResultmethod of your parent activity. There you can uniquely identify the child activity by therequestCodeparameter (if you care that to be unique).From the
Intentparameter of this method you can retrieve the extra values passed from the child activity, such asintent.getStringExtraorintent.getSerializableExtra.