I send data to the server and for this I use AsynTask and in the doInBackgraund() method doInBackgraund() send
urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setRequestProperty("Content-Type", newValue); urlConnection.setRequestMethod("POST"); urlConnection.setDoInput(true); urlConnection.setDoOutput(true); urlConnection.connect(); bos = new BufferedOutputStream(urlConnection.getOutputStream()); bos.write(data); bos.flush(); But what to do if something with the connection? I have implemented it so that when data starts sending, ProgressDialog() turns on and when sending completes, it turns off. But when something is connected, it keeps spinning and nothing happens.
Is it possible to somehow put the counter on the fact that if something is with the connection, then after 5 seconds, turn off and show the sending error.?
But here is the second point that there may be a bad Internet connection and the data is simply being sent for a long time.
How to make the error function work exactly if something is connected to the server?