如何在启动Android设备时发送短信或电子邮件 [英] How to send SMS or email on starting of android device

查看:105
本文介绍了如何在启动Android设备时发送短信或电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个小型Android应用程序,在重新启动手机时将SMS发送到预定义的手机号码(或电子邮件)。我使用了从各个站点建议的几个代码。但这些都行不通。附加我当前使用的代码。 (但它不发送消息......)



请帮助我..提前致谢..



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..

@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();
        }
    };

推荐答案

你需要确保你的代码完全启动意识





看看:



http://stackoverflow.com/questions/8950854/auto-start-application-after-boot-completed-in -android [ ^ ]







http://stackoverflow.com/questions/17542286/how-to-launch-activity -on-broadcastreceiver-when-boot-complete-on-android [ ^ ]



/ Darren
You need to make sure your code is boot complete aware


Take a look at:

http://stackoverflow.com/questions/8950854/auto-start-application-after-boot-completed-in-android[^]

and

http://stackoverflow.com/questions/17542286/how-to-launch-activity-on-broadcastreceiver-when-boot-complete-on-android[^]

/Darren


这篇关于如何在启动Android设备时发送短信或电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆