My application will take pictures and I need the user to hold the phone smoothly. And if the position of the phone does not match the condition, then toast will appear on the screen.

1) How to track the position of the phone?

2) and how is it properly called?

I know that this is used in games, when a car goes, for example, and the user turns the phone right or left and the application reacts to it ...

    2 answers 2

    I think you need an Accelerometer. Here is just a tutorial , try it!

    • I have such a problem, I use an accelerometer, but I understand it determines the position of the phone relative to the cardinal points (North, south, etc.) and plus uses magnetic fields (Sensor.TYPE_MAGNETIC_FIELD), and because of this my indicators always change + / - 10 in different directions ... although the device is still in place ... Maybe there is a way to accurately measure the position of the XYZ axes? Can a gyroscope give such an opportunity? So that if the phone is standing still, the figures do not jump and are correctly displayed - Aleksey Timoshchenko

    Read here . This article has answers to both questions.

    • I have such a problem, I use an accelerometer, but I understand it determines the position of the phone relative to the cardinal points (North, south, etc.) and plus uses magnetic fields (Sensor.TYPE_MAGNETIC_FIELD), and because of this my indicators always change + / - 10 in different directions ... although the device is still in place ... Maybe there is a way to accurately measure the position of the XYZ axes? Can a gyroscope give such an opportunity? So that if the phone is standing still, the figures do not jump and are correctly displayed - Aleksey Timoshchenko