Methods Summary |
---|
public static void | actionCancel(android.content.Context context)
Intent i = new Intent();
i.setClass(context, MailService.class);
i.setAction(MailService.ACTION_CANCEL);
context.startService(i);
|
public static void | actionReschedule(android.content.Context context)
Intent i = new Intent();
i.setClass(context, MailService.class);
i.setAction(MailService.ACTION_RESCHEDULE);
context.startService(i);
|
private void | cancel()
AlarmManager alarmMgr = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent();
i.setClassName("com.android.email", "com.android.email.service.MailService");
i.setAction(ACTION_CHECK_MAIL);
PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
alarmMgr.cancel(pi);
|
public android.os.IBinder | onBind(android.content.Intent intent)
return null;
|
public void | onDestroy()
super.onDestroy();
MessagingController.getInstance(getApplication()).removeListener(mListener);
|
public void | onStart(android.content.Intent intent, int startId)
super.onStart(intent, startId);
this.mStartId = startId;
MessagingController controller = MessagingController.getInstance(getApplication());
controller.addListener(mListener);
if (ACTION_CHECK_MAIL.equals(intent.getAction())) {
if (Config.LOGD && Email.DEBUG) {
Log.d(Email.LOG_TAG, "*** MailService: checking mail");
}
// Only check mail for accounts that have enabled automatic checking. There is still
// a bug here in that we check every enabled account, on every refresh - irrespective
// of that account's refresh frequency - but this fixes the worst case of checking
// accounts that should not have been checked at all.
// Also note: Due to the organization of this service, you must gather the accounts
// and make a single call to controller.checkMail().
ArrayList<Account> accountsToCheck = new ArrayList<Account>();
for (Account account : Preferences.getPreferences(this).getAccounts()) {
if (account.getAutomaticCheckIntervalMinutes() != -1) {
accountsToCheck.add(account);
}
}
Account[] accounts = accountsToCheck.toArray(new Account[accountsToCheck.size()]);
controller.checkMail(this, accounts, mListener);
}
else if (ACTION_CANCEL.equals(intent.getAction())) {
if (Config.LOGD && Email.DEBUG) {
Log.d(Email.LOG_TAG, "*** MailService: cancel");
}
cancel();
stopSelf(startId);
}
else if (ACTION_RESCHEDULE.equals(intent.getAction())) {
if (Config.LOGD && Email.DEBUG) {
Log.d(Email.LOG_TAG, "*** MailService: reschedule");
}
reschedule();
stopSelf(startId);
}
|
private void | reschedule()
AlarmManager alarmMgr = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent();
i.setClassName("com.android.email", "com.android.email.service.MailService");
i.setAction(ACTION_CHECK_MAIL);
PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
int shortestInterval = -1;
for (Account account : Preferences.getPreferences(this).getAccounts()) {
if (account.getAutomaticCheckIntervalMinutes() != -1
&& (account.getAutomaticCheckIntervalMinutes() < shortestInterval || shortestInterval == -1)) {
shortestInterval = account.getAutomaticCheckIntervalMinutes();
}
}
if (shortestInterval == -1) {
alarmMgr.cancel(pi);
}
else {
alarmMgr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime()
+ (shortestInterval * (60 * 1000)), pi);
}
|