Skip to content Skip to sidebar Skip to footer

Json Can't Get Int Value From Php

My problem is simple. I can't get the value of item from php and my android app crashes. My PHP: My Java Android:

Solution 1:

Wouldn't json.getInt require "value" as the parameter not the URL? so json.getInt("value")

Solution 2:

When you're grabbing the integer from your JSONObject, the key you inputted is the url which doesn't make sense. Try changing it to

control = json.getInt("value");

Solution 3:

your error log shows that you are making a network call on the main thread (NetworkOnMainThreadException), which android prohibits. You will have to move the call for getting the JSON to a separate thread. Using an Async Task will accomplish this.

Solution 4:

You can try this:

<?php$control = array('value' => 0);
echo json_encode($control);
?>

Post a Comment for "Json Can't Get Int Value From Php"