Can you have two activities running at the same time?

后端 未结 2 1500
无人及你
无人及你 2020-12-06 20:59

What I have is an activity with a severer, and another activity with different information on it. However when I open the non-sever activity the sever closes. Is there a wa

2条回答
  •  广开言路
    2020-12-06 21:39

    You cannot have multiple activities running at the same time. If you want code to run in the background you need to use a Service. For more information checkout the docs: http://developer.android.com/reference/android/app/Service.html

    You should program your server as a Service and then write an Activity that communicates with the server and displays relevant information. This way when you navigate to a new Activity the server continues to run.

提交回复
热议问题