Android - Make sure we call Interface enterBackground when opening the app

This commit is contained in:
Cristian Luis Duarte 2018-06-07 18:22:58 -03:00
parent 082c1fce52
commit 2b0ac6a9bd
2 changed files with 15 additions and 1 deletions

View file

@ -56,6 +56,8 @@ public class InterfaceActivity extends QtActivity {
private AssetManager assetManager;
private static boolean inVrMode;
private boolean nativeEnterBackgroundCallEnqueued = false;
// private GvrApi gvrApi;
// Opaque native pointer to the Application C++ object.
// This object is owned by the InterfaceActivity instance and passed to the native methods.
@ -121,13 +123,19 @@ public class InterfaceActivity extends QtActivity {
@Override
protected void onPause() {
super.onPause();
nativeEnterBackground();
if (super.isLoading) {
nativeEnterBackgroundCallEnqueued = true;
} else {
Log.d("[ENTERBACKGROUND]","onPause calling nativeEnterBackground");
nativeEnterBackground();
}
//gvrApi.pauseTracking();
}
@Override
protected void onStart() {
super.onStart();
nativeEnterBackgroundCallEnqueued = false;
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
@ -256,6 +264,10 @@ public class InterfaceActivity extends QtActivity {
public void onAppLoadedComplete() {
super.isLoading = false;
if (nativeEnterBackgroundCallEnqueued) {
Log.d("[ENTERBACKGROUND]","onAppLoadedComplete calling nativeEnterBackground");
nativeEnterBackground();
}
}
public void performHapticFeedback(int duration) {

View file

@ -8248,10 +8248,12 @@ void Application::saveNextPhysicsStats(QString filename) {
#if defined(Q_OS_ANDROID)
void Application::enterBackground() {
qDebug() << "[ENTERBACKGROUND] Application::enterBackground()";
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
"stop", Qt::BlockingQueuedConnection);
if (getActiveDisplayPlugin()->isActive()) {
getActiveDisplayPlugin()->deactivate();
qDebug() << "[ENTERBACKGROUND] Application::enterBackground() getActiveDisplayPlugin()->deactivated";
}
}