@@ -71,6 +71,20 @@ public final class JuceDemo extends Activity | |||||
super.onDestroy(); | super.onDestroy(); | ||||
} | } | ||||
@Override | |||||
protected final void onPause() | |||||
{ | |||||
suspendApp(); | |||||
super.onPause(); | |||||
} | |||||
@Override | |||||
protected final void onResume() | |||||
{ | |||||
super.onResume(); | |||||
resumeApp(); | |||||
} | |||||
@Override | @Override | ||||
public void onConfigurationChanged (Configuration cfg) | public void onConfigurationChanged (Configuration cfg) | ||||
{ | { | ||||
@@ -87,6 +101,8 @@ public final class JuceDemo extends Activity | |||||
//============================================================================== | //============================================================================== | ||||
private native void launchApp (String appFile, String appDataDir); | private native void launchApp (String appFile, String appDataDir); | ||||
private native void quitApp(); | private native void quitApp(); | ||||
private native void suspendApp(); | |||||
private native void resumeApp(); | |||||
private native void setScreenSize (int screenWidth, int screenHeight); | private native void setScreenSize (int screenWidth, int screenHeight); | ||||
//============================================================================== | //============================================================================== | ||||
@@ -71,6 +71,20 @@ public final class JuceAppActivity extends Activity | |||||
super.onDestroy(); | super.onDestroy(); | ||||
} | } | ||||
@Override | |||||
protected final void onPause() | |||||
{ | |||||
suspendApp(); | |||||
super.onPause(); | |||||
} | |||||
@Override | |||||
protected final void onResume() | |||||
{ | |||||
super.onResume(); | |||||
resumeApp(); | |||||
} | |||||
@Override | @Override | ||||
public void onConfigurationChanged (Configuration cfg) | public void onConfigurationChanged (Configuration cfg) | ||||
{ | { | ||||
@@ -87,6 +101,8 @@ public final class JuceAppActivity extends Activity | |||||
//============================================================================== | //============================================================================== | ||||
private native void launchApp (String appFile, String appDataDir); | private native void launchApp (String appFile, String appDataDir); | ||||
private native void quitApp(); | private native void quitApp(); | ||||
private native void suspendApp(); | |||||
private native void resumeApp(); | |||||
private native void setScreenSize (int screenWidth, int screenHeight); | private native void setScreenSize (int screenWidth, int screenHeight); | ||||
//============================================================================== | //============================================================================== | ||||
@@ -127,6 +127,16 @@ public: | |||||
*/ | */ | ||||
virtual void systemRequestedQuit() = 0; | virtual void systemRequestedQuit() = 0; | ||||
/** This method is called when the application is being put into background mode | |||||
by the operating system. | |||||
*/ | |||||
virtual void suspended() = 0; | |||||
/** This method is called when the application is being woken from background mode | |||||
by the operating system. | |||||
*/ | |||||
virtual void resumed() = 0; | |||||
/** If any unhandled exceptions make it through to the message dispatch loop, this | /** If any unhandled exceptions make it through to the message dispatch loop, this | ||||
callback will be triggered, in case you want to log them or do some other | callback will be triggered, in case you want to log them or do some other | ||||
type of error-handling. | type of error-handling. | ||||
@@ -60,14 +60,11 @@ JUCEApplication::~JUCEApplication() | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
bool JUCEApplication::moreThanOneInstanceAllowed() | |||||
{ | |||||
return true; | |||||
} | |||||
bool JUCEApplication::moreThanOneInstanceAllowed() { return true; } | |||||
void JUCEApplication::anotherInstanceStarted (const String&) {} | |||||
void JUCEApplication::anotherInstanceStarted (const String&) | |||||
{ | |||||
} | |||||
void JUCEApplication::suspended() {} | |||||
void JUCEApplication::resumed() {} | |||||
void JUCEApplication::systemRequestedQuit() | void JUCEApplication::systemRequestedQuit() | ||||
{ | { | ||||
@@ -161,6 +161,16 @@ public: | |||||
*/ | */ | ||||
virtual void systemRequestedQuit(); | virtual void systemRequestedQuit(); | ||||
/** This method is called when the application is being put into background mode | |||||
by the operating system. | |||||
*/ | |||||
virtual void suspended(); | |||||
/** This method is called when the application is being woken from background mode | |||||
by the operating system. | |||||
*/ | |||||
virtual void resumed(); | |||||
/** If any unhandled exceptions make it through to the message dispatch loop, this | /** If any unhandled exceptions make it through to the message dispatch loop, this | ||||
callback will be triggered, in case you want to log them or do some other | callback will be triggered, in case you want to log them or do some other | ||||
type of error-handling. | type of error-handling. | ||||
@@ -49,6 +49,20 @@ JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, launchApp, void, (JNIEnv* en | |||||
jassert (MessageManager::getInstance()->isThisTheMessageThread()); | jassert (MessageManager::getInstance()->isThisTheMessageThread()); | ||||
} | } | ||||
JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, suspendApp, void, (JNIEnv* env, jobject activity)) | |||||
{ | |||||
JUCEApplicationBase* const app = JUCEApplicationBase::getInstance(); | |||||
if (app != nullptr) | |||||
app->suspended(); | |||||
} | |||||
JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, resumeApp, void, (JNIEnv* env, jobject activity)) | |||||
{ | |||||
JUCEApplicationBase* const app = JUCEApplicationBase::getInstance(); | |||||
if (app != nullptr) | |||||
app->resumed(); | |||||
} | |||||
JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, quitApp, void, (JNIEnv* env, jobject activity)) | JUCE_JNI_CALLBACK (JUCE_ANDROID_ACTIVITY_CLASSNAME, quitApp, void, (JNIEnv* env, jobject activity)) | ||||
{ | { | ||||
JUCEApplicationBase::appWillTerminateByForce(); | JUCEApplicationBase::appWillTerminateByForce(); | ||||
@@ -31,6 +31,8 @@ | |||||
- (void) applicationDidFinishLaunching: (UIApplication*) application; | - (void) applicationDidFinishLaunching: (UIApplication*) application; | ||||
- (void) applicationWillTerminate: (UIApplication*) application; | - (void) applicationWillTerminate: (UIApplication*) application; | ||||
- (void) applicationDidEnterBackground: (UIApplication*) application; | |||||
- (void) applicationWillEnterForeground: (UIApplication*) application; | |||||
@end | @end | ||||
@@ -50,6 +52,20 @@ | |||||
JUCEApplicationBase::appWillTerminateByForce(); | JUCEApplicationBase::appWillTerminateByForce(); | ||||
} | } | ||||
- (void) applicationDidEnterBackground: (UIApplication*) application | |||||
{ | |||||
JUCEApplicationBase* const app = JUCEApplicationBase::getInstance(); | |||||
if (app != nullptr) | |||||
app->suspended(); | |||||
} | |||||
- (void) applicationWillEnterForeground: (UIApplication*) application | |||||
{ | |||||
JUCEApplicationBase* const app = JUCEApplicationBase::getInstance(); | |||||
if (app != nullptr) | |||||
app->resumed(); | |||||
} | |||||
@end | @end | ||||
namespace juce | namespace juce | ||||