2012-04-03 18:58:01 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
package org.mozilla.gecko;
|
|
|
|
|
|
|
|
import android.app.Application;
|
|
|
|
|
2012-07-28 00:53:54 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2012-07-18 00:54:54 +00:00
|
|
|
public class GeckoApplication extends Application {
|
|
|
|
|
2012-09-27 14:52:59 +00:00
|
|
|
private boolean mInited;
|
2012-09-14 15:19:40 +00:00
|
|
|
private boolean mInBackground;
|
2012-04-03 18:58:01 +00:00
|
|
|
|
2012-09-27 14:52:59 +00:00
|
|
|
protected void initialize() {
|
|
|
|
if (mInited)
|
|
|
|
return;
|
|
|
|
|
2012-07-07 05:38:05 +00:00
|
|
|
// workaround for http://code.google.com/p/android/issues/detail?id=20915
|
|
|
|
try {
|
|
|
|
Class.forName("android.os.AsyncTask");
|
|
|
|
} catch (ClassNotFoundException e) {}
|
|
|
|
|
2012-09-14 15:19:40 +00:00
|
|
|
GeckoConnectivityReceiver.getInstance().init(getApplicationContext());
|
|
|
|
GeckoBatteryManager.getInstance().init(getApplicationContext());
|
|
|
|
GeckoBatteryManager.getInstance().start();
|
|
|
|
GeckoNetworkManager.getInstance().init(getApplicationContext());
|
2012-09-19 19:21:19 +00:00
|
|
|
MemoryMonitor.getInstance().init(getApplicationContext());
|
2012-09-27 14:52:59 +00:00
|
|
|
mInited = true;
|
2012-04-03 18:58:01 +00:00
|
|
|
}
|
|
|
|
|
2012-09-14 15:19:40 +00:00
|
|
|
protected void onActivityPause(GeckoActivity activity) {
|
2012-05-08 23:40:12 +00:00
|
|
|
mInBackground = true;
|
|
|
|
|
2012-09-14 15:19:40 +00:00
|
|
|
GeckoAppShell.sendEventToGecko(GeckoEvent.createPauseEvent(true));
|
|
|
|
GeckoConnectivityReceiver.getInstance().stop();
|
|
|
|
GeckoNetworkManager.getInstance().stop();
|
2012-04-03 18:58:01 +00:00
|
|
|
}
|
|
|
|
|
2012-09-14 15:19:40 +00:00
|
|
|
protected void onActivityResume(GeckoActivity activity) {
|
|
|
|
if (GeckoApp.checkLaunchState(GeckoApp.LaunchState.GeckoRunning))
|
|
|
|
GeckoAppShell.sendEventToGecko(GeckoEvent.createResumeEvent(true));
|
|
|
|
GeckoConnectivityReceiver.getInstance().start();
|
|
|
|
GeckoNetworkManager.getInstance().start();
|
2012-05-08 23:40:12 +00:00
|
|
|
|
|
|
|
mInBackground = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isApplicationInBackground() {
|
|
|
|
return mInBackground;
|
2012-04-03 18:58:01 +00:00
|
|
|
}
|
|
|
|
}
|