Finally i solved this issue with some modification in my existing code. Also changed Target level to Android 4.4
from Project->Right Click->Android
public void showGameOverDialog(int score) {
final Dialog dialog = new customeDialogClass(Level1Activity_Room.this,
R.style.DialogBackground);
dialog.setContentView(R.layout.gameover_dialog_layout);
dialog.setCanceledOnTouchOutside(false);
dialog.setCancelable(false);
dialog.show();
}
customeDialogClass.java
@TargetApi(14)
public class customeDialogClass extends Dialog {
public customeDialogClass(Context context) {
super(context);
if (Build.VERSION.SDK_INT < 18) {
return;
}
// The UI options currently enabled are represented by a bitfield.
// getSystemUiVisibility() gives us that bitfield.
int uiOptions = getWindow().getDecorView().getSystemUiVisibility();
int newUiOptions = uiOptions;
boolean isImmersiveModeEnabled = ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions);
if (isImmersiveModeEnabled) {
Log.e("log1---", "Turning immersive mode mode off.");
} else {
Log.e("log2-----", "Turning immersive mode mode on.");
}
// Status bar hiding: Backwards compatible to Jellybean
if (Build.VERSION.SDK_INT >= 16
&& (newUiOptions & View.SYSTEM_UI_FLAG_FULLSCREEN) <= 0) {
newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
}
if (Build.VERSION.SDK_INT >= 18
&& (newUiOptions & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) <= 0) {
newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
}
getWindow().getDecorView().setSystemUiVisibility(newUiOptions);
}
public customeDialogClass(Context context, boolean cancelable,
OnCancelListener cancelListener) {
super(context, cancelable, cancelListener);
}
public customeDialogClass(Context context, int theme) {
super(context, theme);
if (Build.VERSION.SDK_INT < 18) {
return;
}
// The UI options currently enabled are represented by a bitfield.
// getSystemUiVisibility() gives us that bitfield.
int uiOptions = getWindow().getDecorView().getSystemUiVisibility();
int newUiOptions = uiOptions;
boolean isImmersiveModeEnabled = ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions);
if (isImmersiveModeEnabled) {
Log.e("log1---", "Turning immersive mode mode off.");
} else {
Log.e("log2-----", "Turning immersive mode mode on.");
}
// Status bar hiding: Backwards compatible to Jellybean
if (Build.VERSION.SDK_INT >= 16
&& (newUiOptions & View.SYSTEM_UI_FLAG_FULLSCREEN) <= 0) {
newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
}
if (Build.VERSION.SDK_INT >= 18
&& (newUiOptions & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) <= 0) {
newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
}
getWindow().getDecorView().setSystemUiVisibility(newUiOptions);
}
}