• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Cannot send SMS

jl2035

Lurker
I'm building an application which will include a functionality to send sms. I really want a very simple way to do this. It doesn't look so difficult but I can't make it work. I found this cool guide: SMS Messaging in Android | mobiForge ...

...so I used his 'sendSMS' method:
Code:
private void sendSMS(String message, String phoneNo) {
      PendingIntent pi=PendingIntent.getActivity(this, 0, new Intent(), 0);
      SmsManager sms = SmsManager.getDefault();
      sms.sendTextMessage(phoneNo, null, message, pi, null);
    }
When I call the function I get the catch exception.
Code:
if (phoneNo.length()>0 && message.length()>0)  
     {
           try
           {
                 sendSMS(message, phoneNo);
           }
            catch(Exception e)
           {
                 EditText et4=(EditText)findViewById(R.id.EditTextGlavno);
                 et.setText("Something went wrong...");
            }
     }
oh... and guys ... I'm a little bit newby so please be gentle...
 
Back
Top Bottom