Recent

Author Topic: LAMW permission.WRITE_EXTERNAL_STORAGE  (Read 951 times)

microb

  • New Member
  • *
  • Posts: 13
LAMW permission.WRITE_EXTERNAL_STORAGE
« on: September 14, 2022, 07:09:26 pm »
Hello
I use lamw4 on linux to create the application.
how to modify the
WRITE_EXTERNAL_STORAGE permission
thank you

microb

  • New Member
  • *
  • Posts: 13
Re: LAMW permission.WRITE_EXTERNAL_STORAGE
« Reply #1 on: September 15, 2022, 04:19:53 pm »
 this is my source code,but  permission is alway denied.

       procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);
    var
      manifestPermissions: TDynArrayOfString;
    begin
      //https://www.captechconsulting.com/blogs/runtime-permissions-best-practices-and-how-to-gracefully-handle-permission-removal
      //https://developer.android.com/guide/topics/security/permissions#normal-dangerous
      if  IsRuntimePermissionNeed() then   // that is, target API >= 23
      begin
        if IsRuntimePermissionGranted('android.permission.CAMERA') and
           IsRuntimePermissionGranted('android.permission.WRITE_EXTERNAL_STORAGE') then
        begin
          ShowMessage('Good ... we have runtime permissions !');
        end
        else
        begin
          ShowMessage('warning: Requesting Runtime Permission.... please, wait..');
          SetLength(manifestPermissions, 2);

          manifestPermissions[0]:= 'android.permission.CAMERA';  //from AndroodManifest.xml
          manifestPermissions[1]:= 'android.permission.WRITE_EXTERNAL_STORAGE'; //from AndroodManifest.xml

          Self.RequestRuntimePermission(manifestPermissions, 1101);

          SetLength(manifestPermissions, 0);
        end;
      end;
    end;

    procedure TAndroidModule1.AndroidModule1RequestPermissionResult(
      Sender: TObject; requestCode: integer; manifestPermission: string;
      grantResult: TManifestPermissionResult);
    begin
       case requestCode of
         1101:begin
                if manifestPermission = 'android.permission.CAMERA' then
                begin
                    {
                    if grantResult = PERMISSION_GRANTED  then
                      ShowMessage('Success! ['+manifestPermission+'] Permission grant!!! ' )
                    else  //PERMISSION_DENIED
                       ShowMessage('Sorry... ['+manifestPermission+'] DENIED... ' );
                    }
                end;

                if manifestPermission = 'android.permission.WRITE_EXTERNAL_STORAGE' then
                begin

                    if grantResult = PERMISSION_GRANTED  then
                       ShowMessage('Success! ['+manifestPermission+'] Permission grant!!! ' )
                    else  //PERMISSION_DENIED
                       ShowMessage('Sorry... ['+manifestPermission+'] Permission not grant... ' );

                end;
         end;
      end;
    end;

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: LAMW permission.WRITE_EXTERNAL_STORAGE
« Reply #2 on: September 15, 2022, 06:56:24 pm »
Hi, microb!

What is your Android system version?

You need "Camera", too?


Please, put here your "AndroidManifest.xml" file....
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

microb

  • New Member
  • *
  • Posts: 13
Re: LAMW permission.WRITE_EXTERNAL_STORAGE
« Reply #3 on: September 15, 2022, 08:53:16 pm »
Thanks a lot
My android version is 12
the camera no.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2297
Re: LAMW permission.WRITE_EXTERNAL_STORAGE
« Reply #4 on: September 15, 2022, 11:23:27 pm »
From your "AndroidManifest.xml" ....

Quote
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28"/>

That is, "android.permission.WRITE_EXTERNAL_STORAGE"   is possible only until Android 9!

(you can try configure  your project  "targetApi = 28")


In which folder/path do you want save or load your files?




Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

microb

  • New Member
  • *
  • Posts: 13
Re: LAMW permission.WRITE_EXTERNAL_STORAGE
« Reply #5 on: September 16, 2022, 08:08:09 am »
(you can try configure  your project  "targetApi = 28")

how ?


my file for example :
assignfile(fradars,'/storage/emulated/0/Download/radars1');

for information: my application works well on android 4.4
« Last Edit: September 16, 2022, 08:39:11 am by microb »

microb

  • New Member
  • *
  • Posts: 13
Re: LAMW permission.WRITE_EXTERNAL_STORAGE
« Reply #6 on: September 22, 2022, 04:09:45 pm »
hello
if I name my file radars1.jpg I can read it.
in android settings application permissions I have permission only for files and multimedia content.
I don't have the option for all files.
how to do.

 

TinyPortal © 2005-2018