A proximity sensor is a sensor able to detect the presence of nearby objects without any physical contact. Imagine you are playing music on your phone, and you receive a call. The sensor detects the distance to surfaces (cheeks and ears), and it pauses whatever activity you are in the middle of, for you to take the call. When the phone is at a distance from surfaces (cheeks and ears), it automatically resumes its previous activity.
The gravity sensor works when you enable the auto rotate feature on the top of the screen, the screen automatically rotates when you turn the phone.