I am having difficulty connecting an emulated Android Activity to a regular Java program running on my computer. Here are some of the precautions I took that should have fixed them...
- I try to connect to 10.0.2.2, the ipaddress of the localhost that the emulator is on
- I spawn a new thread separate from the UI thread to make the connection. (I didn't do a fancy worker thread, I simply created a new thread and said .start())
So basically thy system is composed of a normal Java program that declares a ServerSocket and then waits at the .accept() method. I kick that program off and hopefully it sits there and waits. I then switch over to my Activity class which has an onClick method of a button. That method invokes the .start() method of my new thread. Inside the .run method of my activity I declare a new Socket and try to connect to the local host.
Do you know of anything else I should be aware of? The primary problem is that nothing happens. I put a break point right after the .accept method call in the local host java program and I never reach it.