0

I try to request LOCATION_HARDWARE permission for reading usb.

in delphi I try this code:

    procedure getPermiss;
    var
        LPermissions: TJavaObjectArray<JString>;
    begin
      LPermissions := TJavaObjectArray<JString>.Create(1);
      LPermissions.Items[0] := StringToJString('android.permission.LOCATION_HARDWARE');
      try
        TAndroidHelper.Activity.requestPermissions( LPermissions, 1);
      except
         on E : Exception do
         begin
           ShowMessage('Exception class name = '+E.ClassName+' ' +E.Message);
         end;
      end;
end;

but on test in Android Phone show this error: "JNIFatal: Invoke Method Not Found"

I see that the requestPermissions method of Activity needs 3 parameters, and in delphi needs only 2.

The method signature on AndroidStudio is requestPermssions(Context, String[], int)

and on delphi is requestPermissions(String[], int)

hidden the first (Context)

Is this difference the problem? how can I solve ?

Tks

Márcio Rossato
  • 971
  • 1
  • 11
  • 20

1 Answers1

1

This is because requestPermissions( ); was introduced in version 24.1.0 of support library (https://developer.android.com/reference/android/support/v4/app/ActivityCompat.html)

Delphi use by default an old version version of support library so without requestPermissions( ); implemented. you can however replace the default support library used by delphi with the new one, you can see example at https://github.com/Zeus64/alcinoe

zeus
  • 12,173
  • 9
  • 63
  • 184