Getting a JSONException: end of input at character 0

后端 未结 6 1790
名媛妹妹
名媛妹妹 2020-11-30 12:41

I have an API in php, that sends data in JSON format. I made the following code, that works fine when I am on wifi. But when I want to download the data from the API when

相关标签:
6条回答
  • 2020-11-30 13:07

    Check if you are asking for permissions to use the Internet.

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    

    in the Android Manifest

    Check out others at Permissions overview @ https://developer.android.com.

    0 讨论(0)
  • 2020-11-30 13:14

    May be you are getting default response with default values. This kind of error comes up when you are not sending your requests properly or sending with wrong parameters. Check This

    0 讨论(0)
  • 2020-11-30 13:17

    This kind of error comes up when response is null.Print Json respone in logcat

    Log.e ( "response", "" + response ), or you can check response on postman also.

    0 讨论(0)
  • 2020-11-30 13:19

    I got this error while debugging an android app on Android Studio via USB. Connection attempts failed with one tablet but not with my regular test tablet. It turned out that the failure was due to the fact that I hadn't enabled WIFI settings on the failing machine. So I enabled WIFI on it and it connected to server OK.

    0 讨论(0)
  • 2020-11-30 13:27

    You are probably getting a blank response. Its not null but the response is empty. So you are getting this error and not a Nullpointer exception

    0 讨论(0)
  • 2020-11-30 13:27

    Sometimes this error is caused as json encode function requires all incoming data to be UTF-8 encoded.

    Try adding mysqli_set_charset($con, 'utf8'); into your php.

    0 讨论(0)
提交回复
热议问题