Jump to content
cupboy

Mobile Permssions component (adrianos santos version)

Recommended Posts

Here is my code:

 

function TfrmMain.SetScreenBrightness(Brightness: Byte):System.string;
var
  iResult : Byte;
  MobilePermissions1 : TMobilePermissions;
begin
  iResult := 0;
  {$IFDEF ANDROID}
  MobilePermissions1 := TMobilePermissions.Create(self);
  MobilePermissions1.Signature.WriteSettings := True;
  MobilePermissions1.Apply;

  if HasPermission('android.permission.WRITE_SETTINGS') then
    begin
      TJSettings_System.JavaClass.putInt(
        TAndroidHelper.Context.getContentResolver,
        TJSettings_System.JavaClass.SCREEN_BRIGHTNESS,
        Brightness);
      iResult := 1;
    end
  else
    ShowMessage('Write Permissions failure!');
   {$ENDIF}
end;

 

 

All I get when I run it on the Android 12 phone is the Write Permissions failure message. Any idea about what the cause would be?

On the phone I have set Modify system settings to Allowed ... still fails.

Well nevermind it is fixed now. Here is the fix:

 // if HasPermission('android.permission.WRITE_SETTINGS') then
  if TJSettings_System.JavaClass.canWrite(TAndroidHelper.Context) then

 

 

GitHub - adrianosantostreina/MobilePermissions: This is a component to turn more easy the request permission in Android 8.x or later.

 

THIS TOPIC CAN BE DELETED (I don't seem to be able to do it myself... thanks)

 

 

 

 

 

Edited by cupboy

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×