I'm programming an app for Android, and all the app works fine on my Android 4.1, but when I'm testing it on my other Android 2.2 all works fine except the form, when you click the button to send the form the app crashes.
I'd tried commenting different of code and I've found the problem in the if-else, but I don't know why I hope you can help me with this.
This code sends the form:
private void createAccount(){
EditText nombre = (EditText) findViewById(R.id.name);
EditText mail = (EditText) findViewById(R.id.mail);
EditText tel = (EditText) findViewById(R.id.phone);
EditText pass = (EditText) findViewById(R.id.pass);
EditText pass2 = (EditText) findViewById(R.id.pass2);
name = nombre.getText().toString();
email = mail.getText().toString();
phone = tel.getText().toString();
pas = pass.getText().toString();
pas2 = pass2.getText().toString();
if(name.isEmpty() == false && email.isEmpty() == false && phone.isEmpty() == false && pas.isEmpty() == false && pas2.isEmpty() == false){
if(pas.equals(pas2)){
respTxt = Cloud.CreateAccout(phone, name, email, pas, tel_id, tel_oper, tel_country);
TextView alert = (TextView)findViewById(R.id.reg_alert);
ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
if(networkInfo != null && networkInfo.isConnected()){
if(respTxt.equals("email")){
alert.setText(getText(R.string.reg_error1));
regBtn.setEnabled(true);
}else if(respTxt.equals("error") || respTxt.equals("errorc")){
alert.setText(getText(R.string.reg_error2));
regBtn.setEnabled(true);
}else if(respTxt.equals("correct")){
SharedPreferences settings = getSharedPreferences(prefs_file, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("AccountCreated", true);
editor.putString("status", "ok");
editor.commit();
Intent move = new Intent(AppRegis.this, HomeAct.class);
startActivityForResult(move, 0);
}
}else{
alert.setText(getText(R.string.noInternet));
regBtn.setEnabled(true);
}
}else{
TextView alert = (TextView)findViewById(R.id.reg_alert);
alert.setText(getText(R.string.reg_alert)+" "+email);
regBtn.setEnabled(true);
}
}else{
TextView alert = (TextView)findViewById(R.id.reg_alert);
alert.setText(getText(R.string.reg_alert2).toString());
regBtn.setEnabled(true);
}
}
LogCat output is
07-11 17:21:26.251: I/dalvikvm(335): Could not find method java.lang.String.isEmpty, referenced from method com.example/testactivity.createAccount()
07-11 17:21:26.251: W/dalvikvm(335): VFY: unable to resolve virtual method 177: Ljava/lang/String;.isEmpty ()Z
07-11 17:21:26.251: D/dalvikvm(335): VFY: replacing opcode 0x6e at 0x0042
07-11 17:21:26.251: D/dalvikvm(335): VFY: dead code 0x0045-0069 in Lcom/example/testactivity/createAccount() (Landroid/content/Context;Lcom/example/testtctivity;I)V
07-11 17:21:26.361: D/AndroidRuntime(335): Shutting down VM
07-11 17:21:26.361: W/dalvikvm(335): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
07-11 17:21:26.371: E/AndroidRuntime(335): FATAL EXCEPTION: main
07-11 17:21:26.371: E/AndroidRuntime(335): java.lang.NoSuchMethodError: java.lang.String.isEmpty
07-11 17:21:26.371: E/AndroidRuntime(335): at com.example.testactivity.createAccount()(testactivity.java:178)
Line where exception is thrown is if(name.isEmpty() == false....