Bluetooth, Sensors & Auto Quiz

ADVANCED › Emerging

On Android 12 (API 31) and higher, which permission must an app request to scan for nearby BLE devices?

Answer: BLUETOOTH_SCAN

BLUETOOTH_SCAN is the runtime permission for discovering BLE devices on API 31+; with the neverForLocation flag it can even avoid requiring location permission.

In BLE, what distinguishes a GATT client from a GATT server?

Answer: The client sends data requests; the server stores data and replies

The GATT client requests data and the server fulfills those requests; this distinction is independent of the central/peripheral roles.

Why should a SensorEventListener typically be unregistered in onPause()?

Answer: Sensors keep running and drain the battery even when the app isn't visible

The framework does not disable sensors based on the activity lifecycle, so leaving a listener registered keeps the sensor active and drains the battery.

Which of these is a software/composite sensor derived from other hardware sensors?

Answer: TYPE_LINEAR_ACCELERATION (software-derived from raw sensor data)

Linear acceleration, like gravity and the rotation vector, is a composite sensor computed in software from raw hardware sensor data.

What is the key difference between Android Auto and Android Automotive OS (AAOS)?

Answer: Android Auto projects a phone app to the car screen; AAOS is a full OS on the car

Android Auto is phone-based projection to a compatible display, whereas Android Automotive OS is the embedded operating system installed in the vehicle itself.

Which library do you use to build navigation and point-of-interest apps that run on both Android Auto and Android Automotive OS?

Answer: Android for Cars App Library (androidx.car.app)

The Car App Library provides templated, distraction-optimized UI shared across Android Auto and AAOS for navigation, POI, and IoT apps.

Why does the Car App Library use a fixed set of templates instead of arbitrary custom UI?

Answer: To enforce distraction-safety limits with a standardized UI

Templates cap interaction complexity to meet driver-distraction guidelines, so apps cannot draw arbitrary UI while the vehicle is in motion.

After a successful BLE connection on Android 12 (API 31)+, which runtime permission gates calling readCharacteristic() and writeCharacteristic()?

Answer: BLUETOOTH_CONNECT

BLUETOOTH_CONNECT is the runtime permission required to communicate with an already-bonded or connected device, including reading and writing characteristics; SCAN only covers discovery.

What does adding android:usesPermissionFlags="neverForLocation" to the BLUETOOTH_SCAN declaration accomplish?

Answer: It asserts scans aren't used to derive location, so no ACCESS_FINE_LOCATION

The neverForLocation flag tells the system the app does not use Bluetooth scans to infer location, which lets it scan on API 31+ without also requesting ACCESS_FINE_LOCATION.

To start receiving notifications from a characteristic, an app calls setCharacteristicNotification(). What additional step is required for the peripheral to actually push updates?

Answer: Write the enable-notification value to the characteristic's CCCD

setCharacteristicNotification() only configures the local stack; the peripheral starts sending notifications only after the client writes the enable value (0x0001) to the characteristic's CCCD descriptor.

What is the correct interpretation of the delay argument (e.g. SENSOR_DELAY_GAME) passed to registerListener()?

Answer: It is only a hint; events may arrive faster or slower than requested

The sampling rate is a hint only; the framework may deliver events at a different rate, and faster rates such as FASTEST or GAME actually increase battery and CPU usage.

What is the purpose of SensorManager.remapCoordinateSystem()?

Answer: Reorienting a rotation matrix for a non-default device orientation

remapCoordinateSystem() reorients a rotation matrix (for example for a landscape app or a device mounted on a different axis) so that getOrientation() returns values relative to the desired frame of reference.

Which set of classes are the core building blocks of an app built with the Android for Cars App Library?

Answer: CarAppService, Session, and Screen

A Car App Library app declares a CarAppService, which creates a Session that hosts a stack of Screen objects, each returning a template; the standard Activity/Fragment stack is not used.

Which sensor is a one-shot trigger sensor that you register with requestTriggerSensor() and that disables itself after firing once?

Answer: TYPE_SIGNIFICANT_MOTION one-shot trigger sensor via requestTriggerSensor()

TYPE_SIGNIFICANT_MOTION is a trigger sensor handled via TriggerEventListener and requestTriggerSensor(); it fires a single event when significant motion is detected and then automatically unregisters itself.

Back to Bluetooth, Sensors & Auto