To launch a container using implicit Intent


I have an android app which needs data to launch. That data must be passed using implicit Intent with custom URI data(myapp://launch/?id={xxxx}).
I created an application with apk but I could not find to launch a container with Intent URI data.
I tried to pass custom data through the --userdata flag but it failed.

How can I configure an application’s manifest to create that application or how can I launch a container with Intent data?

Thanks in advance.

Hi, thanks for reaching out!

This is definitely possible with Anbox Cloud, but it requires you to create a small bootstrap Android application. This bootstrap application will only be used to start the other application with your custom URI.

What we recommend you do is to first:

  1. Install the bootstrap application with AMS
  2. Install the target application with a hook (see How to extend an application)

You will have two APKs: one for the boostrap application and one for the target application. The layout will look like:

├── app.apk
├── hooks
│   └── post-start
├── manifest.yaml
└── target.apk

app.apk is the bootstrap application, target.apk is the application you want to run.

The post-start hook can then install the target application:

#!/bin/sh -ex
if  [ "$CONTAINER_TYPE" = "regular" ]; then
  exit 0
cp "$ADDON_DIR"/target.apk $ANBOX_DIR/data
anbox-shell pm install -t -g /data/target.apk

If you want to use the watchdog, you need to specify both packages:

name: myapp

Then comes the more open-ended part: there are multiple ways for you to pass the URI to the target application.

  • If the custom URI never or rarely changes and you don’t need them to be different for every container, you can just hardcode the custom URI in your boostrap application. If it changes, you can then and update the AMS application by refreshing the APK.
  • If you need to have a different, custom URI per container, you can for instance:
    1. Pass that URI in the userdata
    2. Create a hook to read from the
      userdata at /var/lib/anbox/userdata. A pre-start hook would seem better in
      your case. That hook can then create a custom file in the Android filesystem
      in your application’s data directory.
    3. Read the URI from the file in the Android filesystem with your boostrap
      application and start the target application

As you have full control over that bootstrap application, you could even think of other ways to achieve what you want in that case.

Thank you for your detailed response. :smile: