Bluetooth, Sensors & Auto Interview Questions

ADVANCED › Emerging

How do you use sensors like the accelerometer in an Android app, and how do you avoid draining the battery?

What a strong answer covers: Get the SensorManager, pick a sensor with getDefaultSensor, and register a SensorEventListener with a sampling rate, receiving SensorEvents with values. Register in onStart or onResume and unregister in onStop or onPause, use the slowest sampling rate that works, batch with maxReportLatency, and prefer higher-level APIs like step counter or activity recognition.

How does Bluetooth Low Energy work on Android at a high level?

What a strong answer covers: A central (the phone) scans for advertising peripherals with BluetoothLeScanner, connects with connectGatt, discovers services, and reads, writes or subscribes to characteristics, all through asynchronous BluetoothGattCallback. Android 12+ needs BLUETOOTH_SCAN and BLUETOOTH_CONNECT permissions (with neverForLocation if you don't derive location). Companion Device Manager can simplify pairing.

What are the common pitfalls when working with BLE on Android?

What a strong answer covers: GATT operations must be serialised: issuing a write before the previous one completes fails silently, so you need an operation queue. Callbacks come on binder threads. Devices vary a lot (status 133 errors, connection limits, caching of services), scans are throttled if started too often (5 per 30 seconds), and connections drop, so handle reconnection and timeouts. Always close() the BluetoothGatt.

How would you build an app for Android Auto or another car platform, and what restrictions apply?

What a strong answer covers: For Android Auto, apps use the Car App Library templates (navigation, points of interest, messaging) or media apps use MediaBrowserService and MediaSession, so the car renders the UI with driver distraction rules: limited lists, no custom drawing in most categories, and limited interaction while driving. Android Automotive OS runs apps directly in the car, with similar templates. Test with the Desktop Head Unit and emulators.

Design a feature that connects to a BLE fitness device, streams heart rate during a workout, and keeps working with the screen off.

What a strong answer covers: A foreground service of type connectedDevice (with health type on Android 14+ where appropriate) owns the connection, with a notification showing the workout. A connection manager queues GATT operations, subscribes to the heart rate characteristic, parses values, handles disconnects with backoff reconnection, and exposes a Flow. Write samples to Room in batches. The UI binds to observe state. Handle permissions (BLUETOOTH_CONNECT, notifications), battery optimisation, and the device or Bluetooth turning off.

Back to Bluetooth, Sensors & Auto