I'm writing a code that changes the TextView's text when the orientation is changed I am using the onConfigurationChanged() listener for changing the text
override fun onConfigurationChanged(newConfig: Configuration?) {
super.onConfigurationChanged(newConfig)
val orientation : Int = getResources().getConfiguration().orientation
val oTag = "Orientation Change"
if(orientation == (Configuration.ORIENTATION_LANDSCAPE)){
mytext?.setText("Changed to Landscape")
Log.i(oTag, "Orientation Changed to Landscape")
}else if (orientation == (Configuration.ORIENTATION_PORTRAIT)){
mytext?.setText("Changed to Portratit")
Log.i(oTag, "Orientation Changed to Portratit")
}else{
Log.i(oTag, "Nothing is coming!!")
}
}
but nothing happens not even in the Log
also I have added this attribute to my Activity in manifest file
android:configChanges="orientation"
What am I missing here ? also is there any other way to achieve this?