Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am creating a small android application, which send SMS to pre-defined mobile number (or email) on restarting the phone. I have use several codes which are suggested from various sites. But these are not working. Attaching the code which i use currently. ( But it do not send message... )

Please Help me.. Thanks in advance..

Java
@Override
    public void onCreate()
    {
        super.onCreate();

        Thread th = new Thread(null, task, "NotifyingService");
        th.start();

    }
    private Runnable task = new Runnable()
    {
        public void run()
        {
            String smsmsg=" Your phone is restarted. ";

            SmsManager sms = SmsManager.getDefault();
            String ph="9898989898";
            sms.sendTextMessage(ph, null, smsmsg, null, null);
            SendSMS_OnBoot.this.stopSelf();
        }
    };
Posted
Comments
[no name] 4-May-14 5:07am    
"Using this method requires that your app has the SEND_SMS permission.", http://developer.android.com/reference/android/telephony/SmsManager.html
AjithJoseph 5-May-14 10:13am    
I have given the permission. and when i try to send sms by pressing a button, it is working... But when i use the same code for sending SMS while restart the phone, i do not working.

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900