TalL
TalL

Reputation: 1681

Huawei Android devices - properly requesting permissions for background locations

We develop an application which requires several permissions in order to get the user’s location while in the background.

We are having problems requesting the required permissions on Huawei devices. It seems that in addition to location permission and white listing the app from battery optimizations, an additional step is required in order to disable battery optimizations and enable auto launching:

The problem is we found no way of automatically requesting permission from the user, and the only way we found is having the user manually go to these screens and change the settings.

We did find a shortcut to take us “half way”, to the application settings:

Intent intent = new
Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:"+context.getPackageName()));

But multiple non intuitive actions are still required from the user.

Our aim:

  1. We would very much like to make the process easier for the user. Optimally, to have a system dialog appear which asks the user for the permissions, instead of having him manually change the settings, much like the whitelisting of normal Android devices:

Is it possible using a Huawei specific SDK extension?

  1. If (1) is not possible, at the very least we need a way to know if the user changes these settings or not. Currently we don’t know and cannot inform the user if the application works properly or not!

Upvotes: 1

Views: 1913

Answers (1)

zhangxaochen
zhangxaochen

Reputation: 34037

Are you expecting that your app displays a permission popup so that users can easily assign related permissions to your app?

If yes, you can integrate HMS Core Location Kit into your app. Before performing an operation requiring a permission, your app dynamically checks its permissions.

If your app does not have the required permission, it will display a popup to prompt the user to assign the permission. You can implement the popup with few code lines and users can easily assign permissions in the popup. For details, visit https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/location-guidev4. In addition to dynamic authorization, do not forget to apply for static permissions in the Manifest file.

Upvotes: 1

Related Questions