import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Display;
import android.view.WindowManager;
public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        FragmentManager fm=getFragmentManager();
        FragmentTransaction ft= fm.beginTransaction();
        WindowManager wm= getWindowManager();
        Display d=wm.getDefaultDisplay();
        if (d.getWidth()>d.getHeight())
        {
            Fragment1 f1 = new Fragment1();
            ft.replace(android.R.id.content, f1);
        }
        else
        {
            Fragment2 f2 = new Fragment2();
            ft.replace(android.R.id.content, f2);
        }
    ft.commit();
    }
}
I am trying to use fragments in android and want to display fragment1 when width of display is greater than height of display and fragment2 when height of display is greater than  width of display but when using getWidth() and getHeight() android studio is saying that these methods are depricated. 
Then how to know when width is greater and when height is greater?
 
     
     
     
     
    