I have used accessibility Service to show window overlay, what I want is to hide this when the screen rotates to landscape or when user opens keyboard. Or set to orientation of window overlay to portrait mode only when user rotates to landscape mode in any other application.
I have figured it out at last.
override the onConfigurationChanged(Configuration newConfig)
in AccessibilityService Class that is how you will be able to get screen orientation of window overlay. See the code below:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Checks the orientation of the screen
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show();
}
}