Reputation: 23
I'm new to programming. I am learning how to add variable integer with String number = " ";
below is an example. I'm testing.
Button buttonSend;
int phone =9900990;
public void onClick(View v) {
switch (v.getId()) {
case R.id.buttonSend:
String messageToSend = "#abc";
String number = " ";
SmsManager.getDefault().sendTextMessage(number, null, messageToSend, null, null);
break;
}
}
Upvotes: 0
Views: 136
Reputation: 9700
Button buttonSend;
int phone =9900990;
public void onClick(View v) {
switch (v.getId()) {
case R.id.buttonSend:
String messageToSend = "#abc";
String number = " " + phone;
SmsManager.getDefault().sendTextMessage(number, null, messageToSend, null,null);
break;
}
}
Upvotes: 0
Reputation: 12919
In your case, I think you want:
String number = String.valueOf(phone);
Or
String number = "" + phone;
Or
String number = Integer.toString(phone);
Upvotes: 1
Reputation: 34424
Below is the stuff you are looking for(as per feeling from your question)
String number = " " + 9900990;
But cleaner way is to convert integer to string
String str = String.valueOf(9900990)
Upvotes: 0