I am trying to use the screen brightness third party library and discovered post sdk 23 i need SPECIAL permissions and Found this code from Erel.
I want to use the Brightness Library from Informatix member. However there is no pop up asking for permissions and in the log there is the queue wating for a user repsonse i presume. How do i overcome this please.
I want to use the Brightness Library from Informatix member. However there is no pop up asking for permissions and in the log there is the queue wating for a user repsonse i presume. How do i overcome this please.
WakeLock already held.
** Activity (stopwatch) Create, isFirst = false **
SCREEN BRIGHTNESS PERMISSSIONS
** Activity (stopwatch) Resume **
** Activity (stopwatch) Pause, UserClosed = false **
sending message to waiting queue (activity_permissionresult)
running waiting messages (1)
** Activity (stopwatch) Resume **
** Activity (stopwatch) Pause, UserClosed = false **
** Service (starter) Destroy (ignored)**
Special Permsssions:
Sub GetBrightnessPermissions
Dim rp As RuntimePermissions
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result Then
If CanWriteToSystemSettings = False Then
Dim in As Intent
in.Initialize("android.settings.action.MANAGE_WRITE_SETTINGS", "package:" & Application.PackageName)
StartActivity(in)
Wait For Activity_Resume
If CanWriteToSystemSettings = False Then
Log("no permission...")
Return
End If
End If
End If
End Sub
Sub CanWriteToSystemSettings As Boolean
Log("In can write")
Dim p As Phone
If p.SdkVersion >= 23 Then
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim settings As JavaObject
settings.InitializeStatic("android.provider.Settings.System")
Return settings.RunMethod("canWrite", Array(ctxt))
End If
Return True
End Sub