Skip to content Skip to sidebar Skip to footer

Error: Value Fatal Of Type Java.lang.string Cannot Be Converted To Jsonobject

In Android, I want to implement a login system and I'm having an error in converting a String into a JsonObject. This is my Activity: public class Login extends Activity implements

Solution 1:

Your error is inside the jsonParser.makeHttpRequest function. Probably it is downloading a text from your server, that is not correctly formated.

You have to check what your "http://sorifgroupcom.ipage.com/Android/login.php" is returning.

Im making some request to that URL and i dont get any result (the response has an empty body)

Probably you have to check your php file to see what its returning. If you want, you can try a POST request with this online tool and post here the response body, or you can give me a valid username/password to set as parameters, to see what happens.

also, if you want, you can post the contents of the php file since i would bet money the error is there. Probably your php file is not printing the json

Solution 2:

The answer is in your question :-

java.lang.String cannot be converted to JSONObject

Obviously you are trying to convert a string into json which is not possible by the way. Look at your code again or debug it and tell the error on which the exception is coming. Not just the line number, the code on that line too.

Secondly, you are using ASYNCTASK so don't write these lines :-

StrictMode.ThreadPolicypolicy=newStrictMode.ThreadPolicy.Builder().permitAll().build();

StrictMode.setThreadPolicy(policy);

It is bad coding to use StrictMode

Post a Comment for "Error: Value Fatal Of Type Java.lang.string Cannot Be Converted To Jsonobject"