I know this question has been asked a lot on SO already so I apologize if it is redundant, but I can't seem to find an answer to my specific problem anywhere.
I'm attempting to connect my Android emulator to a localhost. Here is my connection code:
public void readPHP(String filename) throws IOException {
url = new URL("http://10.0.2.2:8000/" + filename);
URLConnection conn = url.openConnection();
InputStream stream = null;
try {
stream = conn.getInputStream();
} catch (IOException e) {
System.out.println(e.getMessage());
}
// more code....
stream.close();
}
I've also added the following line to my manifesto:
<uses-permission android:name="android.permission.INTERNET"/>
The app installs properly with no error messages but when I try to run it from the phone, it crashes with the vague message "Unfortunately, CodeGlass GDK has stopped." I'm sure this is a problem with Android because when I try to run the same code in a simple Java program it works as expected.