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

Apps Sending an SMS

smolloy

Lurker
Nov 16, 2010
1
0
Hi all,
This is my first post here, and my first attempt to write something more complex than HelloWorld!

I'm writing a little app, and I need to send an SMS when a button is clicked. To do that I am using the following code.

Code:
    private OnClickListener clickListener = new OnClickListener() {

        public void onClick(View v) {
            String dest = deststr.getText().toString();
            String msgconts = msgstr.getText().toString();
            
            SmsManager sm = SmsManager.getDefault();
            sm.sendTextMessage(dest, null, msgconts, null, null);
        }
    };
When I install this app on my testing phone (an HTC Desire), it appears to run correctly (i.e. it doesn't crash), and it has the right permissions, but the SMS doesn't arrive on the phone I sent it to.

Can anyone let me know what I've done wrong?

Thanks!
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones