I want to know how to set an android service that listen to a specific port e.g. http://127.0.0.1:12345
Implement your service and use the ServerSocket
class to listen for incoming connections and to act on them. Don't call ServerSocket.accept()
on your UI thread, though. That'll cause your application to not respond. Instead, create a new thread or depending on your actual scenario, an AsyncTask
might be sufficient.