The app does not work when deploying. It "crashes" straight.
Follow the code and the error:
ActMain.java
package desenvmoveluss.com.br.trabalho01;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.*;
import android.view.*;
import android.content.*;
public class ActMain extends AppCompatActivity {
//implements View.OnClickListener
private EditText edtA;
private EditText edtB;
private EditText edtC;
private Button btnOK;
public String resultado;
int a;
int b;
int c;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.act_main);
a=0;
b=0;
c=0;
edtA = (EditText)findViewById(R.id.edtA);
edtB = (EditText)findViewById(R.id.edtB);
edtC = (EditText)findViewById(R.id.edtC);
btnOK = (Button)findViewById(R.id.btnOk);
a = Integer.parseInt(edtA.getText().toString());
b = Integer.parseInt(edtB.getText().toString());
c = Integer.parseInt(edtC.getText().toString());
if ((a < b + c) || (b < a + c) || (c < a+b)){
//triangulo
if((a==b) && (a==c) && (c==b)){
resultado = "Triangulo Equilatero";
}
if((a==b) || (a==c) || (c==b)){
resultado = "Triangulo Isosceles";
}
else{
resultado = "Triangulo Escaleno";
}
}
else{
resultado = "Não é um triangulo";
}
}
public void OnClick(View v){
Intent it = new Intent(this, ActSegundaTela.class);
it.putExtra("RESULTADO", resultado.toString());
startActivity(it);
}
}
ActSegundaTela.java
package desenvmoveluss.com.br.trabalho01;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.*;
import android.view.*;
public class ActSegundaTela extends AppCompatActivity {
private TextView txtResultado;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.act_segunda_tela);
txtResultado = (TextView)findViewById(R.id.txtResultado);
Intent intent = getIntent();
String resultado = intent.getExtras().getString("RESULTADO");
// String valor = bundle.getString("RESULTADO");
txtResultado.setText(resultado);
}
}
Error
09-23 18:05:57.920 8864-8864/desenvmoveluss.com.br.trabalho01 E/AndroidRuntime: FATAL EXCEPTION: main
Process: desenvmoveluss.com.br.trabalho01, PID: 8864
java.lang.RuntimeException: Unable to start activity ComponentInfo{desenvmoveluss.com.br.trabalho01/desenvmoveluss.com.br.trabalho01.ActMain}: java.lang.NumberFormatException: Invalid int: ""
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2434)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
at android.app.ActivityThread.access$900(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5527)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
Caused by: java.lang.NumberFormatException: Invalid int: ""
at java.lang.Integer.invalidInt(Integer.java:138)
at java.lang.Integer.parseInt(Integer.java:358)
at java.lang.Integer.parseInt(Integer.java:334)
at desenvmoveluss.com.br.trabalho01.ActMain.onCreate(ActMain.java:35)
at android.app.Activity.performCreate(Activity.java:6272)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
at android.app.ActivityThread.access$900(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5527)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)