Skip to content
Advertisement

Error parsing data org.json.JSONException: End of input at character 0 of – Android

I’m developing a test Android application that must display some data from a mysql db. Here my logs:

JavaScript

Here the class JSONParser.java

JavaScript

Here the class I use to display the selected data:

JavaScript

Here the php file:

JavaScript

In addition, here the main Activity:

JavaScript

I read various thread around the internet about this error, but it is even caused by differents problems, and I did not found a case similar to mine or a solution that solved my problem.

Advertisement

Answer

Looks like your PHP file is returning invalid response.

If you are writing a handler which returns JSON, it should return valid JSON response ANYWAY.

Here is how it should be:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement