0
public static String getJsonSystem(String urlString){
HttpURLConnection urlConnection = null;
BufferedReader reader = null;
String retorno = "";
try{
URL url = new URL(urlString);
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.connect();
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
reader = new BufferedReader(new InputStreamReader(in));
String line = "";
StringBuffer buffer = new StringBuffer();
while ((line = reader.readLine()) != null){
buffer.append(line);
}
retorno = buffer.toString();
} catch (Exception e){
e.printStackTrace();
}
return retorno;
}
Here as I call the connection:
String caminho = "http://192.168.0.11/system/pages/login";
HttpConnection conexão = new HttpConnection();
String resp = conexão.getJsonSystem(caminho);
AlertDialog.Builder alerta = new AlertDialog.Builder(this);
alerta.setMessage(resp);
alerta.show();
Confirm that the server you want to connect is working. You can connect the server directly to the browser using this URL?
– Rene Freak
Check to see if you’re giving internet access on your Androidmanifest? So:
<uses-permission android:name="android.permission.INTERNET" />
– viana
I tested the url is connecting. How much permission is already in my manifest.
– Felipe
Tooth debug your application and see which line is stopping.
– viana