我正在实现多个时间发送的短信,并且我正在使用每个 for 循环。sendSms
当我在 for 循环中调用方法时,它显示更改类型为Number
to String
。我已经检查了每个数字的if
长度是否大于一,然后发送短信。这是我的代码。
btnSendSms=(Button)findViewById(R.id.button1_SendSms);
btnSendSms.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
String message="Hi HElooo";
String[] number={strCellNo1,strCellNo2,strCellNo3,strCellNo4,strCellNo5};
Log.e("String Array","->"+number);
for(int i=0 ; i<number.length ; i++) {
if(i==0) {
sendSMS(number, stringMessage);
}
}
}
});
public void sendSMS(String number, String message) {
String SENT = "SMS_SENT";
String DELIVERED = "SMS_DELIVERED";
PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(SENT), 0);
PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0, new Intent(DELIVERED), 0);
// SmsManager sms = SmsManager.getDefault();
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(number, null, message, sentPI, deliveredPI);
}
@Override
protected void onStop() {
unregisterReceiver(sendBroadCastReciever);
unregisterReceiver(deliveryBroadCastReciever);
super.onStop();
}