Android Sensors Interview Questions

Motion, location, and sensor APIs.

50 questions in this topic · 8 sample questions below

Practice Sensors in the quiz engine

Sample questions

  1. You call registerListener with SENSOR_DELAY_FASTEST. What does this actually guarantee about how often onSensorChanged fires?

    • Nothing exact; it is only a hint and the system may deliver events slower or coalesce them — correct
    • The exact fastest rate the hardware supports, delivered precisely
    • Events at exactly 200 Hz regardless of device
    • One event per display frame

    Why: The SENSOR_DELAY_* constants are only hints to the framework; actual delivery depends on hardware, other listeners, and system load. It does not guarantee an exact rate, so the answer claiming a precise fastest rate is a common misconception.

  2. TYPE_LINEAR_ACCELERATION differs from TYPE_ACCELEROMETER in what key way?

    • It reports acceleration in degrees per second
    • It reports acceleration with the gravity component removed — correct
    • It reports only the gravity component
    • It is identical but sampled faster

    Why: Linear acceleration is a composite sensor giving device acceleration excluding gravity, whereas the raw accelerometer includes gravity. The claim that it reports only gravity describes TYPE_GRAVITY, not linear acceleration.

  3. A developer assumes the raw accelerometer already subtracts gravity, so a still phone should read near zero on all axes. Why is that wrong?

    • The accelerometer is always exactly zero at rest
    • Gravity only affects the gyroscope
    • The raw accelerometer includes gravity, so a still phone reads about 9.81 on the axis aligned with gravity — correct
    • The accelerometer outputs magnetic flux, not acceleration

    Why: TYPE_ACCELEROMETER includes the gravity vector, so a resting device shows roughly 9.81 m/s^2 on the vertical axis. To get gravity-free values you must use TYPE_LINEAR_ACCELERATION or subtract the gravity estimate.

  4. Which sensor type is a virtual or composite sensor derived from sensor fusion rather than a single physical chip?

    • TYPE_ACCELEROMETER
    • TYPE_MAGNETIC_FIELD
    • TYPE_PRESSURE
    • TYPE_ROTATION_VECTOR — correct

    Why: The rotation vector is a fused or virtual sensor combining accelerometer, gyroscope, and magnetometer data. The accelerometer, magnetometer, and barometer are all raw physical sensors.

  5. What does maxReportLatencyUs in registerListener enable?

    • Sensor batching: events are buffered in a hardware FIFO and delivered in groups to save power — correct
    • A hard cap on how long each callback may run
    • Automatic unregistration after the latency elapses
    • Throttling of the sampling rate to the given period

    Why: maxReportLatency lets the sensor hardware batch samples in its FIFO and deliver them together, reducing wakeups and saving power. It does not change the sampling period nor cap callback duration.

  6. A non-wakeup sensor is batching events while the CPU is asleep and the FIFO fills up. What happens?

    • The CPU is woken immediately to drain the FIFO
    • Events are dropped or the oldest are overwritten until the CPU wakes on its own — correct
    • The sensor throws a hardware exception
    • All batched events are lost when the app resumes

    Why: A non-wakeup sensor does not wake the application processor; if its FIFO fills while the CPU sleeps, older events are dropped or overwritten. A wakeup sensor, by contrast, wakes the CPU to guarantee no event loss.

  7. What is the meaning of the timestamp field in a SensorEvent on modern Android?

    • Milliseconds since the Unix epoch
    • Seconds since the app started
    • Nanoseconds, referenced to the system boot time using the elapsed-realtime clock — correct
    • Microseconds since the listener was registered

    Why: SensorEvent.timestamp is in nanoseconds referenced to boot (the elapsed-realtime clock), not the wall-clock epoch. Treating it as Unix epoch milliseconds is a frequent bug.

  8. Your app reads TYPE_STEP_COUNTER and shows the returned value directly as steps this session, but it starts huge. Why?

    • The counter is in centimeters walked
    • The value is a random seed
    • The counter counts steps for all apps combined per day
    • The counter reports steps cumulatively since the last device boot, not per session — correct

    Why: TYPE_STEP_COUNTER returns the total steps since boot; to get session steps you must record a baseline at start and subtract. It does not reset per app session.

Practice all 50 Sensors questions

These 8 are a sample. The full Sensors bank is scored, tracks your progress, and explains every answer.

Open the quiz

More Android interview topics