Skip to content

Instantly share code, notes, and snippets.

@msomu
Created November 1, 2014 04:33
Show Gist options
  • Select an option

  • Save msomu/4869bea2a197ad4a4579 to your computer and use it in GitHub Desktop.

Select an option

Save msomu/4869bea2a197ad4a4579 to your computer and use it in GitHub Desktop.
Know when the users change their phone orientation to Landscape or Potrait
<activity
android:name=".MyActivity"
android:label="@string/app_name"
android:configChanges="orientation|screenSize">
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if(newConfig.orientation==Configuration.ORIENTATION_LANDSCAPE){
Log.d("SOMU","Orientation Changed to Landscape mode");
}
else if(newConfig.orientation==Configuration.ORIENTATION_PORTRAIT){
Log.d("SOMU","Orientation Changed to Potrait mode");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment