You need to do it this way, for example:
unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, System.Messaging,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Controls.Presentation, FMX.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure MessageResultNotificationMessageHandler(const Sender: TObject; const M: TMessage);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
uses
Androidapi.Helpers, Androidapi.JNI.App, Androidapi.JNI.GraphicsContentViewText;
const
cRequestCode = 1234; // Just a random number
constructor TForm1.Create(AOwner: TComponent);
begin
inherited;
TMessageManager.DefaultManager.SubscribeToMessage(TMessageResultNotification, MessageResultNotificationMessageHandler);
end;
destructor TForm1.Destroy;
begin
TMessageManager.DefaultManager.Unsubscribe(TMessageResultNotification, MessageResultNotificationMessageHandler);
inherited;
end;
procedure TForm1.MessageResultNotificationMessageHandler(const Sender: TObject; const M: TMessage);
var
LMessage: TMessageResultNotification;
begin
LMessage := TMessageResultNotification(M);
if LMessage.RequestCode = cRequestCode then
begin
if LMessage.ResultCode = TJActivity.JavaClass.RESULT_OK then
begin
// Here, handle the Intent that is the LMessage.Value property
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
LIntent: JIntent;
begin
LIntent := TJIntent.Create;
LIntent.setAction(TJIntent.JavaClass.ACTION_PICK);
LIntent.setType(StringToJString('image/*'));
TAndroidHelper.Activity.startActivityForResult(LIntent, cRequestCode);
end;
end