In both FET and RET the smartphones contain accelerometers that measure acceleration and gravity applying to a phone.
The output is then passed to the operating system and then the onscreen app, The apps by default ignore this but a library function can be included to alter the apps layout or functionality.
If you would like more detail I think that android has a java machine between the sensor and the OS.