getCurrentActivity().get() is null when requesting permission

Here’s one of many stack traces from Google Play Console:

JNI DETECTED ERROR IN APPLICATION: obj == null

_JNIEnv::CallObjectMethod(_jobject*, _jmethodID*, …)
sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/jni.h:617:5

juce::FragmentOverlay::open()
modules/juce_core/native/juce_JNIHelpers_android.cpp:742:32

juce::startAndroidActivityForResult(juce::LocalRef<_jobject*> const&, int, std::__ndk1::function<void (int, int, juce::LocalRef<_jobject*>)>&&)
modules/juce_core/native/juce_JNIHelpers_android.cpp:797:15

juce::FileChooser::Native::launch()
modules/juce_gui_basics/native/juce_FileChooser_android.cpp:165:13

buttonClicked(juce::Button*)

Here’s my current version of juce’s FragmentOverlay::open:

734 void FragmentOverlay::open()
735 {
736     auto* env = getEnv();
737
738     LocalRef<jobject> bundle (env->NewObject (AndroidBundle, AndroidBundle.constructor));
739     env->CallVoidMethod (bundle.get(), AndroidBundle.putLong, javaString ("cppThis").get(), (jlong) this);
740     env->CallVoidMethod (native.get(), AndroidFragment.setArguments, bundle.get());
741   
742     LocalRef<jobject> fm (env->CallObjectMethod (getCurrentActivity().get(), AndroidActivity.getFragmentManager));
743     env->CallVoidMethod (native.get(), AndroidDialogFragment.show, fm.get(), javaString ("FragmentOverlay").get());
744 } 

Seems this is related to another issue with the current activity: