InterviewSolution
Saved Bookmarks
| 1. |
I want to pass a String value from one Fragment to another fragment How to do this? |
|
Answer» In, we can send information from one activity to another and vice-versa using startActivityForResult() method. The android startActivityForResult method requires a result from the second activity. For that, we need to override the onActivityResult method that is invoked automatically when the second activity returns a result. public void startActivityForResult (Intent intent, int requestCode)Now we will see how to send data from Activity B back to Activity A?
In Activity B we will send someResultCode to Activity A, which will HANDLE it with the onActivityResult and send it back again with setResult(…) finish(); goBackToActivityA(){ setResult(someResultCode); finish(); }
|
|