I have a FileNotFoundException in an URL, it seems that is the URL doesn't work on the HttpURLConnection because it runs in the browser. The Connection works on other URLs. The URL has a 200 status code so it has a normal code.
That's the AssyncTask code:
private class CrearRegistroTask extends AsyncTask<String, Void, String> {
/*
EJEMPLO DE LA CREACIÓN DE UN REGISTRO
*/
@Override
protected String doInBackground(String... params) {
InputStream iS = null;
String data="";
try {
URL url = new URL("http://user:pass@denunciaty.florida.com.mialias.net/api/reporte/nuevo/Prueba3/Descripcion3/1/Ejempo/2/5/senyal");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setReadTimeout(10000);
con.setConnectTimeout(15000);
con.setRequestMethod("GET");
con.setDoInput(true);
con.connect();
iS = new BufferedInputStream(con.getInputStream());
con.getResponseCode();
if (iS != null) {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(iS));
String line = "";
while ((line = bufferedReader.readLine()) != null)
data += line;
}
iS.close();
return data;
} catch (IOException e) {
e.printStackTrace();
} finally {
if(iS !=null){
try {
iS.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return data;
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
tv.setText(s);
}
}`
`