Handle Server Response in Android

后端 未结 3 761
滥情空心
滥情空心 2021-01-16 16:47

In my application I am fetching data using webservices.But when the server is down or not in active state it gives response code 500 and my application force close.

3条回答
  •  春和景丽
    2021-01-16 17:30

    The problem is that you are creating a JSON object using a response which is empty or does not represent a json string.

    So, you should create a JSON object based on your response if:

    - the status code is 200
    - the response is not empty
    - the response starts with '['
    

提交回复
热议问题