Issue
Apps crashing when attempting to bind to a context of a null object due to improperly handling an Activity transition.
Resolution
Since Android 5.0 uses ART for Ahead of Time Compilation instead of JIT compilation done earlier in Dalvik, it's likely that subtle timings between activity transfers cause issues with bringing up new activities prior to calling finish().
We have seen applications that have tried to implement new activities off of a preexisting context and then calling finish() explicitly. This has led to unpredictable results and crashing under the Android Runtime in Lollipop.
The proper solution here would be to bind your context to getApplicationContext(), rather than an activity context within a transition, as there is no guarantee as to the activity object still being in memory throughout the transition. As getApplicationContext() is bound to your app's process, which is more predictably present in this case.
Keywords: Context, Crashes, JIT, ART, Dalvik
KB_0019