Fix NP when activity detaches from fragment

Change-Id: I9cffdd137683b5a9fa45e21a22e859919a23cd8a
(cherry picked from commit 8ba88c5ebfdb18ae0e0414201ac04e73a3d10ead)