I made an app (proximity sensor) but it is getting crashed everytime.Please solve the error and tell me about it

github link:https://github.com/Ketanpandey77/Working-with-Hardware-Sensors-Android-

Use

proximitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY)!!

in the line: 38

if you control click on getDefaultSensor you can check the supported types. they are:

type == Sensor.TYPE_PROXIMITY || type == Sensor.TYPE_SIGNIFICANT_MOTION
                || type == Sensor.TYPE_TILT_DETECTOR || type == Sensor.TYPE_WAKE_GESTURE
                || type == Sensor.TYPE_GLANCE_GESTURE || type == Sensor.TYPE_PICK_UP_GESTURE
                || type == Sensor.TYPE_WRIST_TILT_GESTURE
                || type == Sensor.TYPE_DYNAMIC_SENSOR_META || type == Sensor.TYPE_HINGE_ANGLE

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.