First, I reduced the screen brightness as low as possible, and then made all GUI elements inaccessible to touch problems. Below is my code:
@Override
public void onSensorChanged(SensorEvent event) {
WindowManager.LayoutParams params = this.getWindow().getAttributes();
if (event.values[0] == 0) {
params.screenBrightness = 0.005f;
this.getWindow().setAttributes(params);
enableDisableViewGroup((ViewGroup)findViewById(R.id.YOUR_MAIN_LAYOUT).getParent(),false);
Log.e("onSensorChanged","NEAR");
} else {
params.screenBrightness = -1.0f;
this.getWindow().setAttributes(params);
enableDisableViewGroup((ViewGroup)findViewById(R.id.YOUR_MAIN_LAYOUT).getParent(),true);
Log.e("onSensorChanged","FAR");
}
}
From here , I turned to turn off the touch screen to view the entire screen.
source
share