From 9d5b41e21220637a04a052b81d239a9678f83701 Mon Sep 17 00:00:00 2001 From: hogliux Date: Tue, 1 Nov 2022 15:38:42 +0100 Subject: [PATCH] Android: Fixed a bug which caused android native dialogs to be presented multiple times in a row --- modules/juce_core/native/juce_android_JNIHelpers.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/juce_core/native/juce_android_JNIHelpers.cpp b/modules/juce_core/native/juce_android_JNIHelpers.cpp index 972c6e1dd9..eb2c3838b3 100644 --- a/modules/juce_core/native/juce_android_JNIHelpers.cpp +++ b/modules/juce_core/native/juce_android_JNIHelpers.cpp @@ -650,8 +650,9 @@ public: void onStart() override { - getEnv()->CallVoidMethod (getNativeHandle(), AndroidFragment.startActivityForResult, - intent.get(), requestCode); + if (! std::exchange (activityHasStarted, true)) + getEnv()->CallVoidMethod (getNativeHandle(), AndroidFragment.startActivityForResult, + intent.get(), requestCode); } void onActivityResult (int activityRequestCode, int resultCode, LocalRef data) override @@ -667,6 +668,7 @@ private: GlobalRef intent; int requestCode; std::function)> callback; + bool activityHasStarted = false; }; void startAndroidActivityForResult (const LocalRef& intent, int requestCode,