Notification and Intenthandler

Integrate into TBM
  x Look at how we currently do notifications.
  x Instead of calling finish when we dont want to bring our app to the
fore after an intent call moveTaskToBack()
  x If we are not Foreground then always keep in back
  x Test receive video
    x In foreground
    x In background
    x Terminated
  x Create class NotificationAlertManager
    x Add notification code from intent handler.
    x Point intent handler to NotificationAlertManager
    x Add remove notifications on resume
    x Copy activity, layout, drawables etc from testTaskManager
    x Factor the intent for creating the native notification and use
for creating lock screen notification.
    x Show lock screen notification under the right conditions (Screen
is off)
      x Pass and include attributes for notification in intent.
      x Do not finish home activity when showing lock screen
notification just keep in background
      x Put task in background and finish lock screen notification for
dismiss
    - Get custom notification tone
  - Test
    - App on VR | VS
    - App Stopped

QUESTION - How can we determine if in a particular lifecycle of our app
we will be in the foreground or in the background
  - onCreate
    - FOREGROUND - When a user launches our app (not an VR or VS intent)
    - BACKGROUND - When we are launched due to a VR or VS intent and go
through onCreate.
  - onNewIntent
    - FOREGROUND - if last state was Pause()
    - BACKGROUND - if last state was Stop()
  - onStop
    - BACKGROUND - always
  - onRestart
    - BACKGROUND - if last state was onNewIntent
    - FOREGROUND - otherwise (user launched us again)

Architecture:
  - Track foreground vs background:
    - Create a boolean flag isForeground in HomeActivity
    - set as follows
      - onCreate depending on intent
      - onNewIntent depending on lastState
      - onStop - false

  - Initialization and persistence:
    - onCreate (boot)
      - ActiveModelsHandler.ensureAll()
      - GCM
    - onPause
      - ActiveModelsHandler.saveAll()