From a7667077f8da814f111455726a5899c99c2b4b5b Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 8 Dec 2020 11:58:35 +0000 Subject: [PATCH] Android: Fixed a crash when juce_gui_extra is not present The default main JuceActivity for JUCE apps calls appNewIntent() in its onNewIntent() implementation which is defined in juce_gui_extra. This commit moves the implementation into juce_gui_basics. --- .../native/juce_android_Windowing.cpp | 21 +++++++++++++++++++ .../native/juce_android_PushNotifications.cpp | 21 ------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_android_Windowing.cpp b/modules/juce_gui_basics/native/juce_android_Windowing.cpp index 4cb678ad3b..42dde15658 100644 --- a/modules/juce_gui_basics/native/juce_android_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_android_Windowing.cpp @@ -1667,4 +1667,25 @@ const int KeyPress::stopKey = extendedKeyModifier + 46; const int KeyPress::fastForwardKey = extendedKeyModifier + 47; const int KeyPress::rewindKey = extendedKeyModifier + 48; +//============================================================================== +struct JuceActivityNewIntentListener +{ + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ + CALLBACK (appNewIntent, "appNewIntent", "(Landroid/content/Intent;)V") + + DECLARE_JNI_CLASS (JavaActivity, JUCE_PUSH_NOTIFICATIONS_ACTIVITY) + #undef JNI_CLASS_MEMBERS + + static void JNICALL appNewIntent (JNIEnv*, jobject /*activity*/, jobject intentData) + { + #if JUCE_PUSH_NOTIFICATIONS && JUCE_MODULE_AVAILABLE_juce_gui_extra + juce_handleNotificationIntent (static_cast (intentData)); + #else + juce::ignoreUnused (intentData); + #endif + } +}; + +JuceActivityNewIntentListener::JavaActivity_Class JuceActivityNewIntentListener::JavaActivity; + } // namespace juce diff --git a/modules/juce_gui_extra/native/juce_android_PushNotifications.cpp b/modules/juce_gui_extra/native/juce_android_PushNotifications.cpp index e108081ee0..ae2f503f79 100644 --- a/modules/juce_gui_extra/native/juce_android_PushNotifications.cpp +++ b/modules/juce_gui_extra/native/juce_android_PushNotifications.cpp @@ -1645,25 +1645,4 @@ bool juce_handleNotificationIntent (void* intent) return false; } -//============================================================================== -struct JuceActivityNewIntentListener -{ - #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ - CALLBACK (appNewIntent, "appNewIntent", "(Landroid/content/Intent;)V") - - DECLARE_JNI_CLASS (JavaActivity, JUCE_PUSH_NOTIFICATIONS_ACTIVITY) - #undef JNI_CLASS_MEMBERS - - static void JNICALL appNewIntent (JNIEnv*, jobject /*activity*/, jobject intentData) - { - #if JUCE_PUSH_NOTIFICATIONS && JUCE_MODULE_AVAILABLE_juce_gui_extra - juce_handleNotificationIntent(static_cast(intentData)); - #else - juce::ignoreUnused(intentData); - #endif - } -}; - -JuceActivityNewIntentListener::JavaActivity_Class JuceActivityNewIntentListener::JavaActivity; - } // namespace juce