Question

I did follow this Connect to wifi tutorial and i was able to connect my phone to my desktop through wifi(router) and i am able to test almost all application wirelessly except those require JSON parsing. I am using wamp server and it is running but i am getting forbidden error.

This is the error in logcat. Can anyone tell me how shall i get rid of this error?? Also in my source code of the application, i did add the ip address of my desktop like this 192.168.0.105/test/stock.php instead of 10.10.0.2

My application works perfectly on the emulator but i am not able to run it on the device.

04-25 20:07:11.172 11847-11874/com.e.myapplication I/System.out﹕ ERROR : Forbidden 04-25 20:07:11.172 11847-11874/com.e.myapplication I/System.out﹕ error 04-25 20:07:11.172 11847-11847/com.e.myapplication E/log_tag﹕ Error parsing data org.json.JSONException: Value error of type java.lang.String cannot be converted to JSONArray

Was it helpful?

Solution 2

I managed to solve the problem changing a setting in the Apache httpd.conf.

Order Deny,Allow
Deny from all
Allow from 127.0.0.1

I changed it to

Order Deny,Allow
Allow from all
Allow from 127.0.0.1

And now my mobile can access the web service.

OTHER TIPS

Value error of type java.lang.String cannot be converted to JSONArray

means that you probably try to map something like this :

name="value"

to an array.

So your Json is wrongly formatted, you must have something like this :

name=["value"]

Since your app works correctly in the emulator, it's probably a communication error. The error you see is certainly the consequence of something else. Look at previous logs and log the json string you are trying to parse. (I'm pretty sure it is not at all what you expect)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top