I'm trying to create a connection to a servlet and send a Json File, here is the part of the code where the app crashes:
 findViewById(R.id.main_login_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finalJson=createJfile();
            try {
                HTTPConnection(finalJson);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    });
The function is the following one:
public void HTTPConnection(String Json) throws IOException{
    URL url;
    url = new URL("http://192.168.0.136:8080/ProgettoProva/AndroidApp");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestMethod("POST");
    conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
    conn.setRequestProperty("Accept", "text/json");
    OutputStreamWriter writer =new OutputStreamWriter(conn.getOutputStream());
    writer.write(Json);
    writer.close();
    conn.disconnect();
}
In the LogCat, nothing is showed. The app just crashed when it starts the function.
 
     
    