MIIISTER NEUGIT
Newbie
I have the following code:
public static String[] GetCategories(APPCLASS i) throws IOException
{
URL url = new URL("http://192.168.1.72/getcategories.php");
URLConnection conn = url.openConnection();
InputStream is = conn.getInputStream();
Writer writer = new StringWriter();
char[] buffer = new char[1024];
try {
Reader reader = new BufferedReader(
new InputStreamReader(is, "UTF-8"));
int n;
while ((n = reader.read(buffer)) != -1) {
writer.write(buffer, 0, n);
}
} finally {
is.close();
}
return writer.toString().split("" +
"");
}
http://192.168.1.72/getcategories.php is an address that does exist in a server on my network. My phone is connected to wifi, and when I go to that address in the browser it brings up the correct information. But when this code is ran in my application, it brings up an error: "Permission Denied (maybe missing INTERNET permission)" How can I fix this?
EDIT: I discovered that it fails at the line "InputStream is = conn.getInputStream();"
public static String[] GetCategories(APPCLASS i) throws IOException
{
URL url = new URL("http://192.168.1.72/getcategories.php");
URLConnection conn = url.openConnection();
InputStream is = conn.getInputStream();
Writer writer = new StringWriter();
char[] buffer = new char[1024];
try {
Reader reader = new BufferedReader(
new InputStreamReader(is, "UTF-8"));
int n;
while ((n = reader.read(buffer)) != -1) {
writer.write(buffer, 0, n);
}
} finally {
is.close();
}
return writer.toString().split("" +
"");
}
http://192.168.1.72/getcategories.php is an address that does exist in a server on my network. My phone is connected to wifi, and when I go to that address in the browser it brings up the correct information. But when this code is ran in my application, it brings up an error: "Permission Denied (maybe missing INTERNET permission)" How can I fix this?
EDIT: I discovered that it fails at the line "InputStream is = conn.getInputStream();"