android - Getting No value of location? -
iam getting friends information name,location etc graph object in response when want location json givea me no value of location..please me , tell me iam doing wrong?
bundle required = new bundle(); required.putstring("fields", "id,name,picture,location,locale,gender,email"); request req = new request(session, "me/friends", required,httpmethod.get, new callback() { @override public void oncompleted(response response){ graphobject is=response.getgraphobject(); // log.w("friendslist", is.tostring()); string location=""; if (is != null) { jsonobject jsonobject = is.getinnerjsonobject(); try { jsonarray myfriendlist=new jsonarray(); jsonarray array = jsonobject.getjsonarray("data"); (int = 0; < array.length(); i++) { jsonobject object = (jsonobject) array.get(i); jsonobject friendlist = new jsonobject(); jsonobject keyfriendlist = new jsonobject(); jsonarray loc = jsonobject.getjsonarray("location"); for(int j=0;j<loc.length();j++){ location=object.get("id").tostring(); if(location==null||location==""||location=="null") { continue; }}
logcat
04-18 18:48:37.360: w/system.err(28862): org.json.jsonexception: no value location 04-18 18:48:37.365: w/system.err(28862): @ org.json.jsonobject.get(jsonobject.java:354) 04-18 18:48:37.365: w/system.err(28862): @ org.json.jsonobject.getjsonarray(jsonobject.java:544) 04-18 18:48:37.365: w/system.err(28862): @ com.example.socialize_us.mainfragment$2.oncompleted(mainfragment.java:106) 04-18 18:48:37.365: w/system.err(28862): @ com.facebook.request$4.run(request.java:1240) 04-18 18:48:37.365: w/system.err(28862): @ android.os.handler.handlecallback(handler.java:605) 04-18 18:48:37.365: w/system.err(28862): @ android.os.handler.dispatchmessage(handler.java:92) 04-18 18:48:37.365: w/system.err(28862): @ android.os.looper.loop(looper.java:137) 04-18 18:48:37.365: w/system.err(28862): @ android.app.activitythread.main(activitythread.java:4666) 04-18 18:48:37.365: w/system.err(28862): @ java.lang.reflect.method.invokenative(native method) 04-18 18:48:37.366: w/system.err(28862): @ java.lang.reflect.method.invoke(method.java:511)
org.json.jsonexception: no value location
this exception tell json not find location
tag
please make sure json
string have array conatined location
tag
jsonarray loc = jsonobject.getjsonarray("location")
Comments
Post a Comment