Problem is that sometimes the server will timeout and not respond or the response for whatever reason, won't make it back and the app will hang while waiting and eventually force a close on the application after a certain length of time.
Everything as is works fine when the server responds, it is the times that it doesn't that the application crashes
Here is the relevant lines...
Using java Syntax Highlighting
- //This is where we send data to server and wait for response, sendRetResponse will return us or object which we will cast and use as an HTTPResponse object
- getResponse(sData.sendRetResponse(sObj.serializeObjReg(mRoad)));
- private void getResponse(HttpResponse response){
- if (response.containsHeader("rStart")){
- try {
- InputStream IS = response.getEntity().getContent();
- ObjectInputStream obj = new ObjectInputStream(IS);
- ridResponse serializedResponse = (ridResponse) obj.readObject();
- obj.close();
- final String theDist = serializedResponse.getRouteID(1).desc;
- //etc. etc. etc.
Parsed in 0.012 seconds, using GeSHi 1.0.8.4
Does anybody have any ideas how I can rework this to only wait x seconds and then retry for example or at least do something politely so the application does not crash? Thanks in advance, really appreciate any help with this as deadline is approaching quickly!