I would like to determine if this is bad practice, since I have implemented this in some locations.
I have two activities, MainActivity and SecondActivity.
If I want to transfer the string “Hello” from Main to Second, I use a class called Transfer. In this class I have a static String that I set to “Hello”, which I access from the onResume method of SecondActivity.
How does android manage the “Transfer” class? Is it tied to MainActivity and destroyed along with it? Is there any other behavior I should be aware of?
Static members exist as long as the app is in the memory.
This approach works fine. Another way to share data between two activities is to make use of
putExtrato put data into second activity andgetExtrasto get the data.