可以有两个活动同时运行?有两个

2023-09-12 23:44:27 作者:溺海°

我有什么是活动与严厉,并与它不同的信息,另一个活动。然而,当我打开非SEVER活动断绝关闭。有没有一种办法,我能得到这个停下来?如果你需要看到任何code我会很高兴地表现出来。

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 way that I can get this to stop? If you need to see any code I would be happy to show it.

推荐答案

您不能在同一时间运行多个活动。如果你想code在后台运行,你需要使用服务。欲了解更多信息,签出的文档: http://developer.android.com/reference/安卓/ APP / Service.html

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.