First of all, I'm new to Android development. I would like to know why my application crashes when I try to convert the ASCII code to characters.
private String crip(String str, String psw) {
int code = 0;
String full_word="";
for (int i= 0; i <= str.length(); i++) {
code=(int)str.charAt(i); // Crashes aqui (eu acho)
full_word+=code;
}
return full_word;
}
And in the onClick event:
crip.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (!psw.getText().toString().isEmpty() && !str.getText().toString().isEmpty()) {
out.setText(crip(str.getText().toString(), psw.getText().toString()));
}
}
});
Is there something wrong?