mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Implement Process::hide for mobile platforms
This commit is contained in:
parent
31c99d3680
commit
671f3eaf94
4 changed files with 31 additions and 4 deletions
|
|
@ -318,6 +318,8 @@ extern AndroidSystem android;
|
|||
METHOD (unbindService, "unbindService", "(Landroid/content/ServiceConnection;)V") \
|
||||
METHOD (startIntentSenderForResult, "startIntentSenderForResult", "(Landroid/content/IntentSender;ILandroid/content/Intent;III)V") \
|
||||
METHOD (getPackageName, "getPackageName", "()Ljava/lang/String;") \
|
||||
METHOD (moveTaskToBack, "moveTaskToBack", "(Z)Z") \
|
||||
METHOD (startActivity, "startActivity", "(Landroid/content/Intent;)V") \
|
||||
|
||||
DECLARE_JNI_CLASS (JuceAppActivity, JUCE_ANDROID_ACTIVITY_CLASSPATH);
|
||||
#undef JNI_CLASS_MEMBERS
|
||||
|
|
|
|||
|
|
@ -55,10 +55,14 @@ JUCE_API void JUCE_CALLTYPE Process::makeForegroundProcess()
|
|||
|
||||
JUCE_API void JUCE_CALLTYPE Process::hide()
|
||||
{
|
||||
#if JUCE_MAC
|
||||
if (! SystemStats::isRunningInAppExtensionSandbox())
|
||||
{
|
||||
#if JUCE_MAC
|
||||
[NSApp hide: nil];
|
||||
#endif
|
||||
#elif JUCE_IOS
|
||||
[[UIApplication sharedApplication] performSelector: @selector(suspend)];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
JUCE_API void JUCE_CALLTYPE Process::raisePrivilege()
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public:
|
|||
*/
|
||||
static void JUCE_CALLTYPE makeForegroundProcess();
|
||||
|
||||
/** Hides the application (on an OS that supports this, e.g. OSX) */
|
||||
/** Hides the application (on an OS that supports this, e.g. OSX, iOS, Android) */
|
||||
static void JUCE_CALLTYPE hide();
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -29,6 +29,14 @@ extern juce::JUCEApplicationBase* juce_CreateApplication(); // (from START_JUCE_
|
|||
namespace juce
|
||||
{
|
||||
|
||||
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
|
||||
METHOD (constructor, "<init>", "()V") \
|
||||
METHOD (setAction, "setAction", "(Ljava/lang/String;)Landroid/content/Intent;") \
|
||||
METHOD (addCategory, "addCategory", "(Ljava/lang/String;)Landroid/content/Intent;") \
|
||||
|
||||
DECLARE_JNI_CLASS (Intent, "android/content/Intent");
|
||||
#undef JNI_CLASS_MEMBERS
|
||||
|
||||
//==============================================================================
|
||||
#if JUCE_IN_APP_PURCHASES && JUCE_MODULE_AVAILABLE_juce_product_unlocking
|
||||
extern void juce_inAppPurchaseCompleted (void*);
|
||||
|
|
@ -793,11 +801,24 @@ ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept
|
|||
return AndroidComponentPeer::currentModifiers;
|
||||
}
|
||||
|
||||
JUCE_API void JUCE_CALLTYPE Process::hide()
|
||||
{
|
||||
if (android.activity.callBooleanMethod (JuceAppActivity.moveTaskToBack, true) == 0)
|
||||
{
|
||||
auto* env = getEnv();
|
||||
|
||||
GlobalRef intent (env->NewObject (Intent, Intent.constructor));
|
||||
env->CallObjectMethod (intent, Intent.setAction, javaString ("android.intent.action.MAIN") .get());
|
||||
env->CallObjectMethod (intent, Intent.addCategory, javaString ("android.intent.category.HOME").get());
|
||||
|
||||
android.activity.callVoidMethod (JuceAppActivity.startActivity, intent.get());
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// TODO
|
||||
JUCE_API bool JUCE_CALLTYPE Process::isForegroundProcess() { return true; }
|
||||
JUCE_API void JUCE_CALLTYPE Process::makeForegroundProcess() {}
|
||||
JUCE_API void JUCE_CALLTYPE Process::hide() {}
|
||||
|
||||
//==============================================================================
|
||||
void JUCE_CALLTYPE NativeMessageBox::showMessageBoxAsync (AlertWindow::AlertIconType /*iconType*/,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue