0

I am working on an app that is basically dependent on services. Issue is when internet is limited then app crash because of jason response is {} so if we try to get object or array at 0 index it crashes and try catch block is not catching the exception so i want to check limited connectivity. I'm checking it while sending post request to server but in that case HttpResponce object take almost 1 to 2 min so i want to improve user experience what should i do any suggestion please .

HttpParams httpParameters = new BasicHttpParams();
int timeoutConnection = 1000;
int timeoutSocket = 1000;
HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);

this time out is not working i guess conection is not establish that is the reason. Any one can please help me to sort out this issue

Hafiz.M.Usman
  • 223
  • 3
  • 21

1 Answers1

0

Why not make your http call asynchrounous. In that way you execute anything until your http call finishes. Or simply check null value or empty of your json.

ellexy
  • 66
  • 1