0

I'm trying to develop an android application that let the user set a time range & a day and send text messages according to the time range & day set by the user ,Now I've completed everything except that I don't know if there is a way to execute the code that checks time & date in background & even if the application is not running , please suggest me any ideas , thanks in advance

user1928775
  • 355
  • 1
  • 5
  • 15

1 Answers1

1

You can use AlarmManager to make Android call your app at a specific time. You can do this pretty simple like this:

AlarmManager.set( AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 
TWENTY_SECONDS, yourPendingIntent )

Then you should register a BroadcastReceiver which will allow Android to send that intent to your application at specified time.

simekadam
  • 7,334
  • 11
  • 56
  • 79
  • this link should help you..it's a very good tutorial on this problematic.. http://www.vogella.com/tutorials/AndroidBroadcastReceiver/article.html – simekadam Feb 08 '14 at 19:06