I got this Error and can't catch Exception. I really confused why I can't catch , Before Works.
Here I've 2 EditText I want to check if it's empty do somework. I used other methods to check is Empty but doesn't work and Exit from app.
Code:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ad=new AlertDialog.Builder(getApplicationContext()).create();
ad.setTitle("خطا");
sp=sp=getSharedPreferences("sp", Activity.MODE_PRIVATE);
bsobh=(Button) findViewById(R.id.Bsobh);
bzohr=(Button) findViewById(R.id.Bzohr);
basr=(Button) findViewById(R.id.basr);
bmaqrib=(Button) findViewById(R.id.bmaqrib);
besha=(Button) findViewById(R.id.besha);
brooze=(Button) findViewById(R.id.brooze);
ok=(Button) findViewById(R.id.ok);
etnamaz=(EditText) findViewById(R.id.ettedaderoozenamaz);
etrooze=(EditText) findViewById(R.id.ettedadroozerooze);
ok.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
try{
int temp=Integer.parseInt(etnamaz.getText().toString());
sobh=temp;
zohr=temp;
asr=temp;
maqrib=temp;
esha=temp;
}
catch(Exception e){
ad.setMessage("لطفا تعداد روزهایی که نمازتان قضا شده است را وارد کتید");
ad.show();
}
try{
rooze=Integer.parseInt(etrooze.getText().toString());
}
catch(Exception e){
ad.setMessage("لطفا تعداد روزهایی که روزه تان قضا شده است را وارد کتید");
ad.show();
}
inserted=true;
update();
}
});
}