Pergunta

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

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top