I have an app that when it launches, starts the main activity, all its okay, this activity sends and listen to info from an XMPP Server. If I change activity this send/read doesn't stop but when I go back to main activity, ** I reconnect to Server. Its okay but the Server read Disconnect-Connect when I go back to main activity from any other activity. My question is, how I can launch the main activity from other without Disconnect-Connect issue (?)** I think maybe exists a method like startActivity but without restart It (I don't use finish)... Only go back to activity showing it, but never stop or start It... Something like show(enable/disable) . The activity works and the second plane and never stop/restart. This activity has a lot of threads that cant be rebooting all time.
Asked
Active
Viewed 41 times
1 Answers
1
Why dont you make you client-server communication in Application class, so you always have the same instance, and you will be able to manually control lifecycle of communication?

Maksym V.
- 2,877
- 17
- 27
-
I think that but, i dont want stop it on any moment... I think better solution is create a first activity that contains de Server methods and with delay launch the main activity (that contains a Map) and the now real first activity never stop – Chuflitas May 10 '18 at 09:06
-
Well, when you starting second activity u have to save state of first one. Take a look here : https://stackoverflow.com/questions/151777/saving-android-activity-state-using-save-instance-state/151940#151940 – Maksym V. May 10 '18 at 09:12
-
Thank u man! But if i edit manifest can i launch both activities at the same time and only show first? – Chuflitas May 10 '18 at 09:14
-
You will still have to launch activities one by one. But as for me, i would make the communication logic separate, and activate it form App class – Maksym V. May 10 '18 at 09:15
-
Hope it really helped – Maksym V. May 10 '18 at 09:18