How to allow Physical activity on Android device?

Hi all,

Recently I encountered the following situation:
My automation testing has to verify mobile application, which uses smart watches/trackers for tracking steps and sleep time.
However, the real Android devices I use do not have “Physical activity” Setting allowed for my application.
This means the application could not display anything related to tracking activity.
Do you know how to allow such setting before the execution of the test?
This is how this setting looks like on the Android emulator:

You say you are using real device, but post screenshot that clearly says, “Android Emulator”.

Maybe this permission doesn’t work on emulators? I would bring a problem like this to developers. Maybe they made a mistake when requesting this permission. Seems like it could very well be a bug in app.

Hey wreed,

I am asking about the real devices. The screenshot of the emulator is for an example purpose, which screen I expect to access on the real Android devices.
Maybe another fact that matters is that I am using the real devices from the Sauce Labs cloud.
It appears that I am not able to access any native app (“Settings”) outside the app under test on these devices.
It seems reasonable to not have the permissions to change settings on the real devices from the cloud provider.
However, I have opened a ticket to the Sauce Labs support, in order to ask for confirmation of my theory.

Ok, now that you explain more it makes sense. I don’t use Sauce so I don’t know what they let you do on those devices. Have you tried locally?

I tried locally on an Android emulator and seems to work fine.
I don’t have a physical Android device, but I will try to request such.
Maybe you are right, we don’t know what they let us do on the devices…I am still pending a feedback from the support.

Try also add in capability allow all permissions.

I would try to look for an appropriate adb shell appops interface. One of available appops permissions is called ACTIVITY_RECOGNITION, which seems to match the one needed by your app. Although, I’m pretty sure Sauce does not allow shell commands execution on their public real devices.

    UiAutomator2Options options = new UiAutomator2Options();