Onconfigurationchanged() Called When Window Size Changed Inward Multi-Window Mode

Posted on

Last postal service demonstrate that onMultiWindowModeChanged() volition live called when your app alter from Full covert manner to Multi-Window Mode, or reverse. How most size changed in Multi-Window Mode?

This instance demonstrate that onConfigurationChanged() volition live called inwards instance of size changed inwards Multi-Window Mode.


Modify MainActivity to override onConfigurationChanged() to demonstrate a Toast.

package com.blogspot.android_er.androidmultiwindow;  import android.content.res.Configuration; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.TextView; import android.widget.Toast;  world bird MainActivity extends AppCompatActivity {      TextView textPrompt;      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);         textPrompt = (TextView)findViewById(R.id.prompt);          if(isInMultiWindowMode()){             textPrompt.setText("onCreate run In Multi Window Mode ");         }else{             textPrompt.setText("onCreate run NOT In Multi Window Mode ");         }          Toast.makeText(MainActivity.this,                 "onCreate() called", Toast.LENGTH_LONG).show();     }      @Override     world void onMultiWindowModeChanged(boolean isInMultiWindowMode) {         super.onMultiWindowModeChanged(isInMultiWindowMode);          if(isInMultiWindowMode){             textPrompt.setText("It is In Multi Window Mode ");         }else{             textPrompt.setText("It is NOT In Multi Window Mode ");         }          Toast.makeText(MainActivity.this,                 "onMultiWindowModeChanged() called", Toast.LENGTH_LONG).show();     }      @Override     world void onConfigurationChanged(Configuration newConfig) {         super.onConfigurationChanged(newConfig);          Toast.makeText(MainActivity.this,                 "onConfigurationChanged() called", Toast.LENGTH_LONG).show();     } }  

The layout file popular off on using that inwards last post.

The AndroidManifest.xml inwards this instance purpose the default setting past times Android Studio without whatever changed.

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.blogspot.android_er.androidmultiwindow">      <application         android:allowBackup="true"         android:icon="@mipmap/ic_launcher"         android:label="@string/app_name"         android:supportsRtl="true"         android:theme="@style/AppTheme">         <activity android:name=".MainActivity">             <intent-filter>                 <action android:name="android.intent.action.MAIN" />                  <category android:name="android.intent.category.LAUNCHER" />             </intent-filter>         </activity>     </application>  </manifest> 

Next:
– Get display data using DisplayMetrics, inwards Multi-Window Mode