validation - Force Stop Error at RunTime MySQL and form validator Android -


i have project that

  1. gets user details
  2. sends user details mysql server

now want make edittexts not empty .

or characters more 3.

my code works when user sends invalid or empty details.

but when edittexts filled correctly application show forcestop error.

public class register extends activity {     public edittext name, lastname, phonenumber, email, username, password, namee, lastnamee, phonenumberr, usernamee, passwordd;     private fbutton reg_btn_login;     private progressdialog pdialog;     jsonparser jsonparser = new jsonparser();     private static final string login_url = "http://mojtabaapp.esy.es/register.php";     private static final string tag_success = "success";     private static final string tag_message = "message";     // baresi edit text ha     public boolean ayavorodysahihbood() {         namee = (edittext) findviewbyid(r.id.et_name);         lastnamee = (edittext) findviewbyid(r.id.et_famili);         phonenumberr = (edittext) findviewbyid(r.id.et_phone);         usernamee = (edittext) findviewbyid(r.id.user);         passwordd = (edittext) findviewbyid(r.id.pass);         boolean n, l, ph, u, p;         n = name.gettext().tostring().length() > 3;         l = lastnamee.gettext().tostring().length() > 3;         ph = phonenumberr.gettext().tostring().length() == 11;         u = usernamee.gettext().tostring().length() > 5;         p = passwordd.gettext().tostring().length() > 5;         if (n | l | ph | u | p) {             return false;          } else return true;      }     private boolean isnetworkconnected() { // check internet connection         connectivitymanager cm = (connectivitymanager) getsystemservice(context.connectivity_service);         networkinfo ni = cm.getactivenetworkinfo();         if (ni == null) {             // there no active networks.             return false;         } else return true;     }     public void namayeshbededialog() {         new materialdialog.builder(this)             .title(string.title_dialog)             .content(string.dialog_content)             .positivetext(string.bashe)         //   .negativetext(string.mikham_brm)         .show();         new materialdialog.builder(this)             .callback(new materialdialog.buttoncallback() {@override             public void onpositive(materialdialog dialog) {                 // dialog.dismiss();             }@override             public void onnegative(materialdialog dialog) {                 //finish();             }         });     }     //method namayesh dialog email eshteba     public void namayesh_dialog_email_eshteba() {         alertdialog.builder abb = new alertdialog.builder(this);         abb.settitle(r.string.title_dialog);         abb.setmessage(r.string.email_eshteba_ast);         abb.setpositivebutton(talash_mojadad, new dialoginterface.onclicklistener() {             public void onclick(dialoginterface dialog, int which) {                 finish();                 startactivity(getintent());             }         });         abb.seticon(android.r.drawable.ic_dialog_alert);         abb.show();     }     //method namayesh shomare eshteba     public void namayesh_dialog_shomare_eshteba() {         alertdialog.builder abbb = new alertdialog.builder(this);         abbb.settitle(r.string.title_dialog);         abbb.setmessage(r.string.phonenumber_is_incorrect);         abbb.setpositivebutton(talash_mojadad, new dialoginterface.onclicklistener() {             public void onclick(dialoginterface dialog, int which) {                 finish();                 startactivity(getintent());             }         });         abbb.seticon(android.r.drawable.ic_dialog_alert);         abbb.show();     }@override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_register);         // tarif ha         name = (com.rengwuxian.materialedittext.materialedittext) findviewbyid(r.id.et_name);         lastname = (com.rengwuxian.materialedittext.materialedittext) findviewbyid(r.id.et_famili);         phonenumber = (com.rengwuxian.materialedittext.materialedittext) findviewbyid(r.id.et_phone);         reg_btn_login = (fbutton) findviewbyid(r.id.reg_btn_login);         email = (com.rengwuxian.materialedittext.materialedittext) findviewbyid(r.id.et_mail);         // aya addres email sahih mibashad ?         reg_btn_login.setonclicklistener(new onclicklistener() {@override             public void onclick(view v) {                 if (isnetworkconnected() == false) {                     namayeshbededialog();                     return;                 }                 if (ayavorodysahihbood()) {                     namayeshbededialog();                     return;                 }                 new createuser().execute();             }         });         if (isnetworkconnected() == false) {              namayeshbededialog();         }     }     class createuser extends asynctask < string, string, string > {         boolean failure = false;@override         protected void onpreexecute() {             super.onpreexecute();             pdialog = new progressdialog(register.this);             pdialog.setmessage("..???? ??? ??? ????");             pdialog.setindeterminate(false);             pdialog.setcancelable(true);             pdialog.show();         }@override         protected string doinbackground(string...args) {             // todo auto-generated method stub             // check success tag             int success;             string name = name.gettext().tostring();             string lastname = lastname.gettext().tostring();             string mail = email.gettext().tostring();             int phone = integer.parseint(phonenumber.gettext().tostring());             int cash = 0;             try {                 // building parameters                 list < namevaluepair > params = new arraylist < namevaluepair > ();                 params.add(new basicnamevaluepair("username", name));                 params.add(new basicnamevaluepair("password", lastname));                 params.add(new basicnamevaluepair("emailaddres", mail));                 params.add(new basicnamevaluepair("phonenumber", string.valueof(phone)));                 params.add(new basicnamevaluepair("usercash", string.valueof(cash)));                 log.d("request!", "starting");                 //posting user data script                 jsonobject json = jsonparser.makehttprequest(                 login_url, "post", params);                 // full json response                 log.d("login attempt", json.tostring());                 // jon success element                 success = json.getint(tag_success);                 if (success == 1) {                     log.d("user created!", json.tostring());                     finish();                     return json.getstring(tag_message);                 } else {                     log.d("login failure!", json.getstring(tag_message));                     return json.getstring(tag_message);                 }             } catch (jsonexception e) {                 e.printstacktrace();             }             return null;         }         protected void onpostexecute(string file_url) {             // dismiss dialog once product deleted             pdialog.dismiss();             if (file_url != null) {                 toast.maketext(register.this, file_url, toast.length_long).show();             }          }     }@override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu; adds items action bar if present.         getmenuinflater().inflate(r.menu.menu_register, menu);         return true;     }@override     public boolean onoptionsitemselected(menuitem item) {         // handle action bar item clicks here. action bar         // automatically handle clicks on home/up button, long         // specify parent activity in androidmanifest.xml.         int id = item.getitemid();         //noinspection simplifiableifstatement         if (id == r.id.action_settings) {             return true;         }         return super.onoptionsitemselected(item);     } } 


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -