Added activity listener to app to capture transition events.
[#65318234] Check the instance before trying trying to get the current activity. Defensive coding.