diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java index 5d0a5863..ab1ef884 100755 --- a/framework/src/org/apache/cordova/CordovaActivity.java +++ b/framework/src/org/apache/cordova/CordovaActivity.java @@ -28,6 +28,7 @@ import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; +import android.content.res.Configuration; import android.graphics.Color; import android.media.AudioManager; import android.os.Bundle; @@ -441,4 +442,21 @@ public class CordovaActivity extends Activity { super.onSaveInstanceState(outState); cordovaInterface.onSaveInstanceState(outState); } + + /** + * Called by the system when the device configuration changes while your activity is running. + * + * @param newConfig The new device configuration + */ + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + if (this.appView == null) { + return; + } + PluginManager pm = this.appView.getPluginManager(); + if (pm != null) { + pm.onConfigurationChanged(newConfig); + } + } } diff --git a/framework/src/org/apache/cordova/CordovaPlugin.java b/framework/src/org/apache/cordova/CordovaPlugin.java index 95a39c79..0d081178 100644 --- a/framework/src/org/apache/cordova/CordovaPlugin.java +++ b/framework/src/org/apache/cordova/CordovaPlugin.java @@ -26,6 +26,7 @@ import org.json.JSONArray; import org.json.JSONException; import android.content.Intent; +import android.content.res.Configuration; import android.net.Uri; import java.io.FileNotFoundException; @@ -338,4 +339,12 @@ public class CordovaPlugin { public boolean onReceivedClientCertRequest(CordovaWebView view, ICordovaClientCertRequest request) { return false; } + + /** + * Called by the system when the device configuration changes while your activity is running. + * + * @param newConfig The new device configuration + */ + public void onConfigurationChanged(Configuration newConfig) { + } } diff --git a/framework/src/org/apache/cordova/PluginManager.java b/framework/src/org/apache/cordova/PluginManager.java index 93060096..7115bb14 100755 --- a/framework/src/org/apache/cordova/PluginManager.java +++ b/framework/src/org/apache/cordova/PluginManager.java @@ -24,6 +24,7 @@ import java.util.LinkedHashMap; import org.json.JSONException; import android.content.Intent; +import android.content.res.Configuration; import android.net.Uri; import android.os.Debug; import android.util.Log; @@ -488,4 +489,17 @@ public class PluginManager { } return ret; } + + /** + * Called by the system when the device configuration changes while your activity is running. + * + * @param newConfig The new device configuration + */ + public void onConfigurationChanged(Configuration newConfig) { + for (CordovaPlugin plugin : this.pluginMap.values()) { + if (plugin != null) { + plugin.onConfigurationChanged(newConfig); + } + } + } }