I have two activities.The first has some layouts and the second has a switch/toggle.What i want to do is when i change the toggle from the second activity to hide the layouts in the first activity. Now,i know i can use SharedPreferences but i find it hard to believe that i can't reference stuff from one activity in another. For example : howcan i call a method from activity A in activity B? How can i like modifiy a textView from activity A in activity B? Like,pressing a button in activity B to change a textView in activity A directly,not thru SharedPreferences or anything like that. Isn't there some way to reference it ? I'm probably gonna need to do this and i can't believe it isn't possible.
Thanks in advance and have a nice day !
You can use startActivityForResult to start the activity B and after the user finishes to edit the options, you can return to A and send it back your data using the Intent.
Edit:
You could also use a singleton to store some values and have access to them in all your activities but please pay attention when using singletons as you can do memory leaks..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With