Reputation: 1064
As the title, how can I do to "simulate" some values from the emulated heart rate sensor from the emulator? Is this possible on the official emulator or do you know some alternative emulators that do this?
Upvotes: 2
Views: 3071
Reputation: 7716
LOCATE HEART RATE VIRTUAL SENSOR
If you can not find the heart rate sensor under "Additional Sensors" as described in Scott's answer, you need to add this line below to your AVD's config.ini
file.
hw.sensors.heart_rate=yes
For MacOS, the config.ini
file can be found at this path:
/Users/{your user name}/.android/avd/{your AVD name}.avd/config.ini
INCLUDE PERMISSION:
You also need to request the android.permission.BODY_SENSORS
.
This sensor requires permission android.permission.BODY_SENSORS. It will not be returned by SensorManager.getSensorsList nor SensorManager.getDefaultSensor if the application doesn't have this permission.
You can do that using the following methods:
public void permissionRequest(){ if (checkSelfPermission(Manifest.permission.BODY_SENSORS) != PackageManager.PERMISSION_GRANTED) { requestPermissions( new String[]{Manifest.permission.BODY_SENSORS}, MY_PERMISSIONS_REQUEST_BODY_SENSOR); } else{ Log.d(TAG,"ALREADY GRANTED"); } }
OR you can enable it from Settings>Apps>YOUR_APP>Permissions>Sensor
Upvotes: 2
Reputation: 369
Updating this answer for 2021. With the current emulator, you can click "..." in the emulator's menu and navigate to "Virtual Sensors -> Additional Sensors". Here you can move the heart rate slider to control it.
Upvotes: 5
Reputation: 684
No, you can't, android emulator can't simulate any sensors. Android Wear emulators can't do it too
Upvotes: 2