JGuizard
4/3/2016 - 7:36 PM

Get orientation change

Get orientation change

   /*ADD THIS TO ACTIVITY
           <activity android:name=".MyActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:launchMode="singleTask">
   */
   
    @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();
        }
    }