Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to request permission on Android Things?

I'm trying to write to a value on AT. I've already declared required permission as follow in manifest,

<uses-permission android:name="android.permission.WRITE_SETTINGS"/>

And try to request permission at run-time, AT shows windows regarding permission setup. However the switch is not clickable. Regarding AT document

Requesting Permissions at Runtime is not supported because embedded devices aren't guaranteed to have a UI to accept the runtime dialog. Declare permissions that you need in your app's manifest file. All normal and dangerous permissions declared in your app's manifest are granted at install time.

However Settings.System.canWrite() always returns false.

Are there any special methods to enable permission WRITE_SETTINGS?

like image 587
ierturk Avatar asked Feb 16 '17 18:02

ierturk


People also ask

What is request code in Android permission?

// Request Code is used to check which permission called this function. // This request code is provided when the user is prompt for permission. override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {

What are special permissions in Android?

Special Permissions These are those permissions that are neither Normal permissions nor Dangerous permissions. Most of the applications should not use these permissions because they are very sensitive and you need user authorization before using these permissions.


1 Answers

Like you said, the documents say:

Declare permissions that you need in your app's manifest file. All normal and dangerous permissions declared in your app's manifest are granted at install time.

Therefore you don't see the normal Android permissions UI.

From the release notes:

Dangerous permissions requested by apps are not granted until the next device reboot. This includes new app installs and new elements in existing apps.

So try powering off and on your Android Things device

like image 116
Blundell Avatar answered Sep 18 '22 13:09

Blundell