我想在短信中打破新的一线。
这是我的代码:
public void sendSMS()
{
String time;
SimpleDateFormat dayFormat = new SimpleDateFormat("HH:mm:ss", Locale.US);
Calendar calendars = Calendar.getInstance();
time = dayFormat.format(calendars.getTime());
String phoneNumber = "xxxxxxxx";
String message = "This SMS Was sent at : " + time + ". Ruang = " + ruang + ". Lantai = " + lantai + "nama = " + nama_mahasiswa + "No = " + noHP_orangtua;
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, null, null);
}
在String消息中,我想添加break新行,以便显示更好看。 你能帮帮我吗?
答案 0 :(得分:2)
试试这个
String message = "This SMS Was sent at : " + time + ".\nRuang = " + ruang + ". Lantai = " + lantai + "nama = " + nama_mahasiswa + "No = " + noHP_orangtua;
字符串中的“\ n”可能会起作用,但我从未使用过android中的短信,所以我无法确定它是否可行。