4
SMS를 보내는 모듈이있는 앱을 만듭니다. 나는 2 개의 방송 수신기와 보류 된 의도를 사용하고 있는데, 하나는 SMS에 대해 확인 응답을 전송하고 다른 하나는 배달에 사용합니다. SMS 수신자는 브로드 캐스트 수신기를 전송했지만 정상적으로 전송되지 않습니다.Android SMS 배달 방송 수신기가 에뮬레이터에서 작동하지 않습니다.
서비스에서 다음 코드를 사용합니다.
PendingIntent sentPI = PendingIntent.getBroadcast(this, 0,
new Intent(SENT), 0);
PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,
new Intent(DELIVERED), 0);
//---when the SMS has been sent--- is working alright
registerReceiver(new BroadcastReceiver()
{
public void onReceive(Context arg0, Intent arg1)
{
switch (getResultCode())
{
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS sent",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
Toast.makeText(getBaseContext(), "Generic failure",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
Toast.makeText(getBaseContext(), "No service",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
Toast.makeText(getBaseContext(), "Null PDU",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
Toast.makeText(getBaseContext(), "Radio off",
Toast.LENGTH_SHORT).show();
break;
}
unregisterReceiver(this);
}
}, new IntentFilter(SENT));
//---when the SMS has been delivered--- this part is not working
registerReceiver(new BroadcastReceiver()
{
@Override
public void onReceive(Context arg0, Intent arg1)
{
switch (getResultCode())
{
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS delivered",
Toast.LENGTH_SHORT).show();
break;
case Activity.RESULT_CANCELED:
Toast.makeText(getBaseContext(), "SMS not delivered",
Toast.LENGTH_SHORT).show();
break;
default :
Toast.makeText(getBaseContext(), "Unable to generate delivery Report",
Toast.LENGTH_SHORT).show();
}
unregisterReceiver(this);
}
}, new IntentFilter(DELIVERED));
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, msg, sentPI, deliveredPI);
신경 쓰지 마라. .. 그것은 세포에서 일했다. .. 나는 에뮬레이터 –
의 가능한 복제물에 실제로 시험하고 있었다 [안드로이드 : 에뮬레이터에서 SMS 배달 확인을받지 못했다] (http://stackoverflow.com/questions/9503585/) android-not-receiving-sms-delivered-confirm-in-emulator) – Flow