JavaEar 专注于收集分享传播有价值的技术资料

Run time & date checking in Background

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


  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.