You can combine IntentService
with AlarmManager
. When sim card changed, your broadcastReceiver
should start your intent service, then service send an email and schedule the next time to send. Take a look at this answer and make sure you know when to stop sending email to avoid drain battery.
Your service should look like:
@Override
protected void onHandleIntent(Intent intent)
{
// send email.
// check whether or not sending next time
if(canSendNextTime()){
scheduleNextUpdate();
}
}