I'm making an app that has a very specific medical calculator. In the ADL, the calculation appears divinely well. On real devices, it gives error and the application is closed.
Can anyone help me there?
CalcActivity:
package unicatolicaquixada.edu.br.dia_diagnsticodeincidentalomaadrenal;
private EditText txtDVP, txtDT, txtDSC;
private Button btnCalcular, btnLimpar;
private double dvp, dt, dsc;
private String wr, wa;
private TextView firstPercent, secondPercent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_calc);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setTitle("Sair");
txtDVP = (EditText) findViewById(R.id.txtDVP);
txtDT = (EditText) findViewById(R.id.txtDT);
txtDSC = (EditText) findViewById(R.id.txtDSC);
btnCalcular = (Button) findViewById(R.id.btnCalcular);
btnCalcular.setOnClickListener(this);
btnLimpar = (Button) findViewById(R.id.btnLimpar);
btnLimpar.setOnClickListener(this);
firstPercent = (TextView) findViewById(R.id.textView54);
secondPercent = (TextView) findViewById(R.id.textView55);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case android.R.id.home:
startActivity(new Intent(this, MainActivity.class));
finishAffinity();
break;
default:break;
}
return true;
}
@Override
public void onClick(View view) {
if (view.equals(btnCalcular)){
if (txtDVP.getText().toString().equals("") || txtDT.getText().toString().equals("") || txtDSC.getText().toString().equals("")){
wa = "0,00%";
wr = "0,00%";
}else {
dvp = Double.parseDouble(txtDVP.getText().toString());
dt = Double.parseDouble(txtDT.getText().toString());
dsc = Double.parseDouble(txtDSC.getText().toString());
wa = String.valueOf(washoutAbsoluto(dvp,dt,dsc));
secondPercent.setText(wa+"%");
wr = String.valueOf(washoutRelativo(dvp,dt));
firstPercent.setText(wr+"%");
}
}else if (view.equals(btnLimpar)){
firstPercent.setText("0,00%");
secondPercent.setText("0,00%");
txtDVP.setText("");
txtDT.setText("");
txtDSC.setText("");
}
}
private double washoutAbsoluto (double densidadeVenosaPortal, double densidadeTardia, double densidadeSemContraste){
double wa = 100*((densidadeVenosaPortal-densidadeTardia)/(densidadeVenosaPortal-densidadeSemContraste));
return arredondaValores(wa);
}
private double washoutRelativo (double densidadeVenosaPortal, double densidadeTardia){
double wr = 100*((densidadeVenosaPortal-densidadeTardia)/(densidadeVenosaPortal));
return arredondaValores(wr);
}
private double arredondaValores (double valorArredondar){
DecimalFormat formatador = new DecimalFormat("0.00");
valorArredondar = Double.parseDouble(formatador.format(valorArredondar));
return valorArredondar;
}