android - How can I solve these errors: acAppName=/system/bin/surfaceflinger and org.json.JSONObject cannot be converted to JSONArray? -


i'm running api rest application mobile device and, apparently, doesn't have error because doesn't close or kill process automaticaly. run without retrieving me information , shows me 2 erros in log console.

here 1 of problems saw in log console: acappname=/system/bin/surfaceflinger.

    06-04 16:49:21.527  17600-17600/com.example.user.project v/phonewindow﹕ decorview setvisiblity: visibility = 0 ,parent =viewroot{420a1478 com.example.user.project/com.example.user.project.mainactivity,ident = 0}, =com.android.internal.policy.impl.phonewindow$decorview{4205a608 v.e..... r.....id 0,0-0,0}     06-04 16:49:21.527  17600-17600/com.example.user.project d/activitythread﹕ act-launch_activity handled : 0 / activityrecord{4204b3c0 token=android.os.binderproxy@4204aa68 {com.example.user.project/com.example.user.project.mainactivity}}     06-04 16:49:21.590  17600-17600/com.example.user.project e/﹕ appname=com.example.user.project, acappname=/system/bin/surfaceflinger     06-04 16:49:21.590  17600-17600/com.example.user.project e/﹕ 0     06-04 16:49:21.590  17600-17600/com.example.user.project e/﹕ appname=com.example.user.project, acappname=/system/bin/surfaceflinger     06-04 16:49:21.590  17600-17600/com.example.user.project e/﹕ 0     06-04 16:49:21.592  17600-17600/com.example.user.project d/graphicbuffer﹕ create handle(0x614af178) (w:480, h:800, f:1)     06-04 16:49:21.593  17600-17600/com.example.user.project i/maliegl﹕ [mali]window_type=1, is_framebuffer=0, errnum = 0 

and lines below problem:

06-04 17:32:24.340  23481-23503/com.example.user.project i/system.out﹕ >dosendrequest 06-04 17:32:24.341  23481-23503/com.example.user.project i/system.out﹕ <dosendrequest 06-04 17:32:24.382  23481-23503/com.example.user.project e/serviciorest﹕ org.json.jsonexception: value {//here information retrieved of json} of type org.json.jsonobject cannot converted jsonarray 06-04 17:32:24.399  23481-23481/com.example.user.project d/listview﹕ measureheightofchildren adapter=com.com.example.user.project 

i searched both errors first 1 couldn't find helped me second 1 found this: org.json.jsonobject cannot converted jsonarray in android

and wanted apply rajareddy polamreddy said:

jsonobject object = new jsonobject(result);     jsonarray jarray = object.getjsonarray("contacts");     (int = 0; < jarray.length(); i++) {       jsonobject jasonobject = jarray.getjsonobject(i); 

but don't know how apply code:

 httpclient httpclient = new defaulthttpclient();   httpget method = new httpget(url);   method.setheader("content-type", "application/json");      try{          httpresponse response = httpclient.execute(method);          string responsestring = entityutils.tostring(response.getentity());          jsonarray responsejson = new jsonarray(responsestring);             for(int i=0; i<responsejson.length(); i++){                 jsonobject object = responsejson.getjsonobject(i);             }      }catch{          log.e("servicerest", ex.tostring());             } 

where url uri access get method of api rest.

note: i'm using mobile device access uri. instead of localhost, because i'm in external device, i'm using ip network of computer. tried 10.0.2.2 , doesn't work please avoid answers recommend me use 10.0.2.2 ip.

note2: have these permissions on manifest:

<uses-permission android:name="android.permission.write_external_storage"/> <uses-permission android:name="android.permission.read_external_storage"/> <uses-permission android:name="android.permission.internet"/> 

are both erros related? how can solve them? know why first 1 appears?

thanks in advance!

edit

what retrieve of json (i simplified it, put here different types of data retrieving):

int idmain = object.getint("idmain"); string date = object.getstring("date"); string name = object.getstring("name"); double value = object.getdouble("value");  simpledateformat sdf = new simpledateformat("yyyy-mm-dd hh:mm:ss"); date datepar = sdf.parse(date); 

the issue casting. trying retreive object , cast jsonarray jsonobject. app doesnt crash because surrond try/catch (btw: code missing exception after catch). if post sample of json take further , u solve it.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -