My android client makes a URLconnection to a servlet deployed on jboss. But when i run the client in emulator there seems to be no connection being established. My client code:
URL url = new URL("http://192.168.56.1:8080/hello");
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
ObjectOutputStream out=new ObjectOutputStream(connection.getOutputStream());
String s=new String("success");
out.writeObject(s);
out.flush();
out.close();
There is no response in jboss. 192.168.56.1 is the ip address of my machine. Since 'localhost' will refer to the emulator itself, I have used 192.168.56.1.(ipcofig) What is the problem.
This is after I made the suggested changes(i.e gave the internet permission in android manifest.xml and changed the url to 'http://10.0.2.2:8080/hello' to refer to my machine). But i still get this exception when I run my application(Client):
ActivityManager: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.Client/.ClientActivity } from null (pid=-1, uid=-1) requires android.permission.INTERNET
Now it is working. I added the in internet permission to the manifest tag. Earlier I had added it inside the application tag. With reference to my original question, still there is no response from the jboss server evene after making all the suggested changes. There seems to be no connection being made between the emulator and the jboss server.