Android Question Screen Brightness Library

Azhar

Active Member
Licensed User
Longtime User
Hi

I'm trying to use the 3rd Party Brightness library.
Can anyone tell me where I'm going wrong with the permissions?

The problem is that the Brightness command doesn't raise the Activity_PermissionResult request.

Thanks


B4X:
Sub btnTap_Click

  
    'brightness from 0 to 255
    rp.CheckAndRequest("android.permission.WRITE_SETTINGS")
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)

and...

Sub Activity_PermissionResult (Permission As String, Result As Boolean)
    Log("In Activity_PermissionResult")
    Log("Permission is " & Permission & "  Result is " & Result)

    If Permission = "android.permission.WRITE_SETTINGS" Then
        If Result Then
            Log("Permission Granted")
            br.SetScreenBrightnessMode(br.MODE_MANUAL)
            br.SetScreenBrightness(10)
        Else
            'permission not granted so do nothing
            Log("Permission is NOT Granted")
        End If
      
    Else
        Log("some other permission request")
    End If
  
End Sub


and the Manifest Editor looks like this:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.DarkTheme)
'End of default text.
AddPermission(android.permission.ACCESS_NOTIFICATION_POLICY)
AddPermission(android.permission.WRITE_SETTINGS)
 
Last edited:

Azhar

Active Member
Licensed User
Longtime User
Ok thanks Erel. I think I'll practice with a dedicated app to get permissions sorted in order to learn from it.
 
Upvote 0
Top