Merge pull request #121 from catdawg/master

Added onTrimMemory and onLowMemory to Android extension callbacks.
This commit is contained in:
Joshua Granick
2014-04-02 08:58:13 -07:00
2 changed files with 49 additions and 0 deletions

View File

@@ -108,4 +108,28 @@ public class Extension {
}
/**
* Called when the overall system is running low on memory,
* and actively running processes should trim their memory usage.
* This is a backwards compatibility method as it is called at the same time as
* onTrimMemory(TRIM_MEMORY_COMPLETE).
*/
public void onLowMemory () {
}
/**
* Called when the operating system has determined that it is a
* good time for a process to trim unneeded memory from its process.
*
* See http://developer.android.com/reference/android/content/ComponentCallbacks2.html for the level explanation.
*/
public void onTrimMemory (int level) {
}
}

View File

@@ -492,6 +492,31 @@ public class GameActivity extends Activity implements SensorEventListener {
}
@Override public void onLowMemory () {
super.onLowMemory ();
for (Extension extension : extensions) {
extension.onLowMemory ();
}
}
@Override public void onTrimMemory (int level) {
super.onTrimMemory (level);
for (Extension extension : extensions) {
extension.onTrimMemory (level);
}
}
@Override public void onSensorChanged (SensorEvent event) {