java - Code runs but does not send an sms -


i trying send sms. code runs not send sms. there no bugs. please guide must have gone wrong.

package com.example.smsbomber;   import android.app.activity;  import android.os.bundle; import android.telephony.smsmanager; import android.view.menu;  public class mainactivity extends activity {      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);         sendsms();     }       @override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu; adds items action bar if present.         getmenuinflater().inflate(r.menu.main, menu);         return true;     }      public void sendsms() {         string phonenumber = "00923002228885";         string message = "hello world!";          smsmanager smsmanager = smsmanager.getdefault();         smsmanager.sendtextmessage(phonenumber, null, message, null, null);     } }    

try code instead:

smsmanager sms = smsmanager.getdefault(); pendingintent sentpi; string sent = "sms_sent";  sentpi = pendingintent.getbroadcast(this, 0,new intent(sent), 0);  sms.sendtextmessage(phonenumber, null, message, sentpi, null); 

as taken here.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -