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.