我正在實現sms發送時間多個數字,我使用每個for循環。當我在for循環中調用sendSms
方法時,它顯示更改類型Number
到String
。我已檢查if
條件中的每個數字是否數字長度大於1,然後發送短信。這是我的代碼。如何在Android中使用每個for循環
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();
}
是什麼問題? – 2013-04-23 05:45:00
和你的問題是? – 2013-04-23 05:45:02
你有什麼問題? – 2013-04-23 05:45:29