Jump to content
delphi64

FMX: receiving arguments from an Android app

Recommended Posts

I'm writing a FMX app (lets call it appD) for Android in Delphi 11.3 that has to be called/started - and receive some data - from an Android app (let's call it appF) developed by another team (they use Flutter).

AppF uses an intent like this for calling my app:

      AndroidIntent(
        action: "android.intent.action.launch.from.appF",
        package: "com.test.appd",
        arguments: {
         "userId": "User01”,
         "token": "SomeToken"
        },
        flags: [0123456],
      )

 

My app, appD, starts when called by tappF, but I'm unable to receive the data I need (userID, token and flags).

I have made some experiments with the following code from the sample project ReceiveIntent.dproj, but without success:

 

function TForm1.HandleIntentAction(const Data: JIntent): Boolean;
var
  Extras: JBundle;
  jsonMsg: string;
begin
  Result := False;
  if Data <> nil then
  begin
    Memo1.ClearContent;
    Extras := Data.getExtras;
    if Extras <> nil then begin
      jsonMsg := JStringToString(Extras.getString(TJIntent.JavaClass.EXTRA_TEXT));
      Memo1.Text := jsonMsg;
    end;
    Invalidate;
  end;
end;

 

This function is called and I get no errors, but jsonMsg is always empty.

I'm a noob as per Android development... can someone show me the right way to retrieve the arguments passed by the appF? I'm really lost...

Thanks for your time!

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

×