Answer the question
In order to leave comments, you need to log in
Data from the Popup to the calling Activity. How to properly organize?
I have an Activity0 that creates a popup window with an EditText and OK and CANCEL buttons. On the OnClick event of the OK button, you need to transfer the data in the EditText to Activity0.
I wouldn't have any trouble with this if I didn't move the actual creation of the Popup into a separate ToggleValues class. I saw this somewhere and liked it. But now, creating a listener in Activity0 to assign it to a button in another class, I have a situation that has confused me. The listener must be static, and I cannot use the data in Activity0.
I'm not sure that I explained clearly, if I add something with the code.
I feel like I did something stupid. Tell me how to do it right?
I'll add... Having made several variables in Activity0 static, I managed to work with the received data. I just cannot close Activity0 from a static listener in Activity0. But you must.
Answer the question
In order to leave comments, you need to log in
1. forget about static variables in android forever
2. when turning / recreating the activity, unsubscribe the listener from the popup and destroy the popup itself, then re-create the popup and re-transmit the listener
ZYZH also make the listener non-static
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question