The following line should give you ArrayIndexOutOfBounds:
num[5]=Integer.valueOf(spn.toString());
Because you have declared,
int num[] = new int[5];
So your array has five elements with indexes 0,1,2,3,4
Highest index is 4
Change it to
num[4]=Integer.valueOf(spn.toString());
Also change 5 to 4 in the following loops,
for (i=0;i<4;i++){
for(j=i+1;j<4;j++){
Suggestion: It is good to use num.length, instead of using absolute values such as 4 and 5
EDIT:
public void BubbleSort() {
Spannable spn = enterNum.getText();
for (int i = 0; i < spn.length(); i++){
num[i] = Integer.parseInt(""+spn.charAt(i));
}
for (i = 0; i < num.length; i++) {
for (j = i + 1; j < num.length; j++) {
if (num[i] > num[j]) {
temp = num[i];
num[i] = num[j];
num[j] = temp;
}
}
}
String result = "";
for (int i = 0; i < spn.length(); i++){
result += num[i];
}
sortedNum.setText(result);
}