you need to use AlarmManager to trigger alarm at specific peroid or at different intervals..set up a Broadcast Receiver to get the alarm fired….and start an intent service to send emails in the background
an example class to receive alarm in mainactivity:
public void setRepeatingAlarm()
{
Intent intent = new Intent(this, ReceiveAlarm.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0,
intent, PendingIntent.FLAG_CANCEL_CURRENT);
am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(),
(10000 * 1000), pendingIntent);
}
Broadcast Receiver:
public class ReceiveAlarm extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
context.startService(new Intent(context, InService.class));
}
}
Intent service class example:
public class InService extends IntentService
{
public InService() {
super("InService");
// TODO Auto-generated constructor stub
}
@Override
protected void onHandleIntent(Intent intent) {
//send email here
}
}
Declare your broadcast receiver / service class in manifest inside tags
<receiver android:name="ReceiveAlarm" />
<service android:name="InService"></service>
solved In android:how to make a android application to send the report daily at end of the day or 24 hours once [closed]