java - JSON Parser: Error parsing data org.json.,AndroidRuntime: FATAL EXCEPTION: AsyncTask #3 -


it says window licked

package com.example.dd_02.addon; here .java file please answer

public class mainactivity extends activity{

button register; edittext text_name;  private progressdialog pdialog;  jsonparser jparser = new jsonparser();  int status; string message;  private static string url_register = "http://10.0.2.2/apartment/apartment_register.php";  private static final string tag_success = "success"; private static final string tag_message = "message";  @override public void oncreate(bundle savedinstancestate) {      super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     text_name = (edittext) findviewbyid(r.id.txt_apartment_name);      register = (button) findviewbyid(r.id.btn_register);       register.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {                  new apartmentregister().execute();         }     });  } 

{json}

class apartmentregister extends asynctask<string, string, string> {       @override     protected void onpreexecute() {         super.onpreexecute();         pdialog = new progressdialog(mainactivity.this);         pdialog.setmessage("registering apartment..\nplease wait...");         pdialog.setindeterminate(false);         pdialog.setcancelable(false);         pdialog.show();     }     string name1=text_name.gettext().tostring();       protected string doinbackground(string... args) { 

{pasing values}

        list<namevaluepair> params = new arraylist<namevaluepair>();         params.add(new basicnamevaluepair("name",name1));         jsonobject json = jparser.makehttprequest(url_register, "get", params);         log.d("all jobs: ", json.tostring());         try {             // checking success tag             status = json.getint(tag_success);             message = json.getstring(tag_message);          } catch (jsonexception e) {             e.printstacktrace();         }          return null;     }     protected void onpostexecute(string file_url) {          pdialog.dismiss();         if(status == 1){              runonuithread(new runnable() {                 public void run() {                     toast.maketext(getapplicationcontext(), message,toast.length_long).show();                  }             });         }else{             toast.maketext(getapplicationcontext(), message,toast.length_long).show();               intent = new intent(getapplicationcontext(),                     mainactivity.class);              i.addflags(intent.flag_activity_clear_top);             startactivity(i);         }       } } } 

bellow snap of logcate

enter image description here

please find

ohh supposed use get method.that url doesnt respond post requests getting org.json.json exception : end of input @ character 0. because of got null response generated exception.

you have blank response server side not null response empty. getting error , not nullpointer exception


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -