简体   繁体   中英

Android: Sending sms by alarm

in my application user can set an alarm and my application is supposed to send an sms if the user doesn't respond the alarm in time ( let's say alarm goes off at 10:00 pm and user didn't reach the phone to turn it off till 10:15 than the phone will send an sms). I have looked the alarm manager but couldn't figure out how to do that.

you can achieve this by using broadcast receiver. when your user set the alarm on the activity, you can trigger it to send broadcast to the broadcast receiver. you can either execute your task on the broadcast receiver or you can start a service. for reference, check the links below

http://javatechig.com/android/repeat-alarm-example-in-android https://blog.nraboy.com/2014/10/use-broadcast-receiver-background-services-android/

Additionally, make sure that you're app auto start after bootup to make sure that the alarm is not cleared when the phone turns off. For reference, http://karanbalkar.com/2014/01/autostart-application-at-bootup-in-android/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM