Skip to content

ApplicationLifecycle

cketti edited this page Mar 9, 2011 · 3 revisions

Application lifecycle

This page is work in progress. Feel free to contribute.

This is an attempt to describe the current lifecycle of the K-9 Mail application and it's components. The goal is to point out the drawbacks of the current solution and propose changes to improve the situation.

You might want to read:

Application

Every time the K-9 Mail process is started a K9 instance is created (subclass of Application) and initialized using the onCreate() method.

Events that can trigger a process creation:

  • Manual start of the application (e.g. via the launcher app)
  • Intent that invokes a K-9 Mail activity (e.g. compose new message, search)
  • BOOT_COMPLETED broadcast intent
  • DEVICE_STORAGE_LOW broadcast intent
  • DEVICE_STORAGE_OK broadcast intent
  • CONNECTIVITY_CHANGE broadcast intent
  • BACKGROUND_DATA_SETTING_CHANGED broadcast intent
  • SYNC_CONN_STATUS_CHANGED broadcast intent
  • MEDIA_MOUNTED broadcast intent
  • remote control intent is sent by another application
  • AttachmentProvider is used by another application
  • MessageProvider is used by another application

Drawbacks

Currently this is quite expensive as we open the database to read the global settings, check whether some services should be enabled or not, and register some broadcast receivers if necessary. This has the potential to cause long waits before the requested activity is shown. Though most of the time the process will already have been created (because of the BOOT_COMPLETED intent) when an activity is requested to be displayed for the first time.

MailService

...

PollService

...

PushService

...

RemoteControlService

...

SleepService

...

CoreReceiver

...

BootReceiver

...

RemoteControlReceiver

...

AccountReceiver

Currently not used. Seems to be intended as part of the remote control interface.

ShutdownReceiver

...

StorageGoneReceiver

...

StorageReceiver

...

Clone this wiki locally