Fixing a number of problems.

* Bit of a powerhax to determine when the app is actually alive vs when
  we're in the GCM handler service without our main activity running -
  this may break in the future, but it does the job for now. See Cordova
  JIRA bug CB-5186 for some context on the previous problem;
* Fixing a length check on a field which may not exist in the notif
  payload - previously under certain circumstances we got ruined by a
  NullPointerException;
* Rearranging the way that foreground state is set in to the package
  delivered to the app.