Witam!
pisze aplikacje na androida, która ma za zadanie wysyłać sms i przypisywać status wysłania do danego smsa.
Teraz mam pytanie, zrobiłem taką funkcje:
private void sendSMS(String phoneNumber, String message)
{
String wyslany = "SMS_SENT";
String dostarczony = "SMS_DELIVERED";
PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(wyslany), 0);
PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0, new Intent(dostarczony), 0);
registerReceiver(new BroadcastReceiver()
{
public void onReceive(Context arg0, Intent arg1)
{
switch (getResultCode())
{
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS Wysłany", Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
Toast.makeText(getBaseContext(), "Błąd wysyłu!", Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
Toast.makeText(getBaseContext(), "Brak sieci", Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
Toast.makeText(getBaseContext(), "Błąd PDU", Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
Toast.makeText(getBaseContext(), "Brak zasięgu", Toast.LENGTH_SHORT).show();
break;
}
}
}, new IntentFilter(wyslany));
registerReceiver(new BroadcastReceiver()
{
@Override
public void onReceive(Context arg0, Intent arg1)
{
switch (getResultCode())
{
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS dostarczony", Toast.LENGTH_SHORT).show();
break;
case Activity.RESULT_CANCELED:
Toast.makeText(getBaseContext(), "SMS nie dostarczony", Toast.LENGTH_SHORT).show();
break;
}
}
}, new IntentFilter(dostarczony));
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
}
I chciał bym teraz - jako że takich SMSów będę wysyłał np 5 na raz - otrzymać napis SMS dostarczony na nr 631XXXXXX, proszę o podpowiedź jak wyciągnąć numer na który wysyłam?