Sample Code to detect phone flipping could look like this: http://android-er.blogspot.in/2011/02/detect-phone-flipping.html
So basically you should use the accelerometer of your smartphone and place your custom code to onSensorChanged
Pergunta
When music is played in GalaxyS3 (or S4, etc…), if phone is filled upside down, the music is stopped. at this moment, which sensor exactly sensing the "flipping".
Solução
Sample Code to detect phone flipping could look like this: http://android-er.blogspot.in/2011/02/detect-phone-flipping.html
So basically you should use the accelerometer of your smartphone and place your custom code to onSensorChanged
Outras dicas
The accelerometer of the phones can be used to determine the orientation of the phone (when it does not move). This sensor is used to change the screen orientation when you rotate your device, and also to stop the music when you flip it.
For more information on the sensors in your Android device, see: Sensors overview