您可以同时运行两个活动吗? [英] Can you have two activities running at the same time?

查看:33
本文介绍了您可以同时运行两个活动吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我所拥有的是一个更严格的活动,以及另一个具有不同信息的活动.但是,当我打开非服务器活动时,服务器将关闭.有没有办法让我停止这种情况?如果您需要查看任何代码,我很乐意展示它.

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.

推荐答案

您不能同时运行多个活动.如果您希望代码在后台运行,您需要使用 Service.有关更多信息,请查看文档:http://developer.android.com/reference/android/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

您应该将服务器编程为 Service,然后编写一个 Activity 与服务器通信并显示相关信息.这样,当您导航到新的 Activity 时,服务器会继续运行.

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.

这篇关于您可以同时运行两个活动吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆