Hi,
This is a simple application which sends  group  sms (a group consist
only 5 phone numbers )and i have registered  a Broadcast to announce
when an sms is send .here i need to display the number to which the
sms is send ,how to do that
here is my code
# In onCreate()

 button is pressed it triggers  an onClick event and sends the group
sms
public void onClick()
{
       for (int j = 0; j<phonenos.length;j++)
                {
         sendSMS(phonenos[j],mess);
               }
}
 String SENT = "SMS_SENT";
 private void sendSMS(String phoneNumber, String message)
    {

      Intent ss=new Intent(SENT);
     ss.putExtra("phno1", phoneNumber);
      PendingIntent sentPI = PendingIntent.getBroadcast(this, 0,ss,
0);
      SmsManager sms = SmsManager.getDefault();
      sms.sendTextMessage(phoneNumber, null, message, sentPI, null);
}

public void onStart()
    {
        super.onStart();
        br_send=new BroadcastReceiver(){
            @Override
            public void onReceive(Context arg0, Intent arg1) {
                switch (getResultCode())
                {
                    case Activity.RESULT_OK:
                        Toast.makeText(getBaseContext(), "SMS sent
",
                                Toast.LENGTH_SHORT).show();

                        Log.v(TAGS,"intent  :"+arg1.getExtras
().getString("phon1")); //*****error *****
                 }
            }
        };

        registerReceiver(br_send,new IntentFilter(SENT));
}

 public void onStop()
    {
        super.onStop();
        unregisterReceiver(br_del);
}
an error is thrown at arg1.getExtras().getString("phon1") Log
statement  ,is this a right approach to display the number to which
the sms is send

error is
java.lang.RuntimeException: Error receiving broadcast Intent
{ action=SMS_SENT } in seaant.android.panicmessag...@437489e8
 Caused by: java.lang.NullPointerException

Help me to solve this error
Thanks
Ganesh

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to