Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
239 views
in Technique[技术] by (71.8m points)

android - Can you have two activities running at the same time?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...