Hi I don't want to set activity orientation I want to restrict only dialog. Let me know is it possible.
**
Only for Dialog not Activity
.**
Dialog d = new Dialog(context);
Window window = d.getWindow();
window.setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
d.requestWindowFeature(Window.FEATURE_NO_TITLE);
//d.setCancelable(false);
d.setContentView(R.layout.viewpager_main_for_printing);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(d.getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
lp.gravity = Gravity.CENTER;
lp.screenOrientation=WindowManager.LayoutParams./// Here how to set orentation
d.getWindow().setAttributes(lp);
You should check the orientation in that place where you want to show a dialog.
If orientation is portrait then show your dialog.