Everythings work normally but when i run my code i show the log window: No service

OK but; i have an error because debugger say "tag" is null.Why?

onCreate;

Bundle bundle = new Bundle();
bundle.putString("ID", "MY ID NUMBER");

Intent sendintent   = new Intent(SENT);
sendintent.putExtras(bundle);

PendingIntent sentPI        = PendingIntent.getBroadcast(this, 0, sendintent, 0);

onReceive;

registerReceiver(new BroadcastReceiver() {
    public void onReceive(Context context, Intent intent) {
         String tag = intent.getExtras().getString("ID");
         Log.d("ID", tag); <<<NULL
         switch (getResultCode()) {
             case Activity.RESULT_OK:
                 Log.i("SmsSentReceiver", "SMS sent");
                 break;
             case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                 Log.i("SmsSentReceiver", "Generic failure");
                 break;
             case SmsManager.RESULT_ERROR_NO_SERVICE:
                 Log.i("SmsSentReceiver", "No service");
                 break;
             case SmsManager.RESULT_ERROR_NULL_PDU:
                 Log.i("SmsSentReceiver", "Null PDU");
                 break;
             case SmsManager.RESULT_ERROR_RADIO_OFF:
                 Log.i("SmsSentReceiver", "Radio off");
                 break;
          }
       }   
    }
}, new IntentFilter(SENT));

SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage("+xxxxxxx", null, "Hello", sentPI, null);

Related posts

Recent Viewed