last day (14 days later) » 

4:08 PM
0
A: Returned json file doesnot have the jsonArray then cant get the output from the Android Studio

shubhankar sYour server response seems to be an array and not an object, try doing this change instead of casting it into a JSONObject and then trying to get a JSONArray out of it. JSONArray users = new JSONArray(json); Hope it helps!

 
Ben
After i changed it, it still comes out with the errors.
 
What error do you get? Also, can you show me what json is?
 
Ben
I have updated my code.
 
I meant can you paste the string json that you are using? that might help debug better
 
Ben
Ya, its all on the question. Because i have added the whole code on my ParseJSON.java
 
4:08 PM
And you are passing a string manually or is it a server response? A log or a print of that string is what i meant
Hi, can we continue it here?
 
Ben
Hi
Thanks for helping me.
Sorry for didnt understand well about your question
 
when you are calling parseJSON() method
what is the parameter you are sending in the method
 
Ben
I send a request to the server, then the server will return me the json file
Then i will use the parsejson to handle the json file and put it into the listview
 
can you do a log of the file the server is returning?
and show it to me?
 
Ben
[
{
"id": 3,
"title": "asdiasjdaklsj",
"description": "dfkldjskdhjsfkldjsfkl",
"owner": "kyaaa",
"start": "01/27/2016 12:00 AM",
"end": "01/28/2016 12:01 AM"
}]
This is what the server response to me
Is that what you mean?
 
4:16 PM
yes
let me check
and what exception do you get?
 
Ben
It is the result that return from my server, i want to use the result and display it on my list view.
 
does your app crash while parsing it or after?
 
Ben
But i not sure what is the problem on the android studio, it will keep tells me the app is not working.
Ya
 
what does the logcat show
 
Ben
It will crash
 
4:19 PM
?
 
Ben
FATAL EXCEPTION: main
Process: net.simplifiedcoding.volleysample, PID: 32407
java.lang.NullPointerException: storage == null
at java.util.Arrays$ArrayList.<init>(Arrays.java:38)
at java.util.Arrays.asList(Arrays.java:155)
at android.widget.ArrayAdapter.<init>(ArrayAdapter.java:128)
at net.simplifiedcoding.volleysample.CustomList.<init>(CustomList.java:25)
at net.simplifiedcoding.volleysample.MainActivity.showJSON(MainActivity.java:59)
at net.simplifiedcoding.volleysample.MainActivity.access$000(MainActivity.java:18)
at net.simplifiedcoding.volleysample.MainActivity$1.onResponse(MainActivity.java:42)
at net.simplifiedcoding.volleysample.MainActivity$1.onResponse(MainActivity.java:39)
It wil show the error like this.
 
so none of this crash is because of your parse class
it seems to be happening when you are setting the list to the adapter
 
Ben
ya, thats why, i discover that is when i parse the data back, without the json array
What the list to the adapter?
jsonObject = new JSONObject(json);
users = jsonObject.getJSONArray(JSON_ARRAY);

ids = new String[users.length()];
titles = new String[users.length()];
descriptions = new String[users.length()];
owners = new String[users.length()];
starts = new String[users.length()];
ends = new String[users.length()];
Is that this one?
 
no, where do you add the data to your adapter?
CustomList.java:25
this file and line number
if im not wrong
 
Ben
4:39 PM
wait ya
super(context, R.layout.list_view_layout, ids);
This is the line 25
DO you have any idea how come will be like this?
And this is the example that i followed, tested, it works and get the data
 

last day (14 days later) »