Run APK

Kalipso - Form - Actions - Actions Description - Group Others - Run APK

Executes a specified function on a specified APK or JAR file.

Action available for the following operating systems:

Parameters

General

  • APK File <string> - Defines the full path and name of the APK or JAR file that contains the function to run. If LoadAPK Action hasn’t been called, Kalipso loads the APK, run this Action and then unloads the APK.

  • Class Name <string> - Fully classified class name that contains the function to execute.

  • Method Name <string> - Java Method name that you want to run. This method must be a static method.

  • Run Mode <numeric>

    • 1- UI Thread In this case, the code is executed from the UI thread and you can invoke user interactive code directly.

    • 2- Background Thread In this case, the code is executed in a background thread. If you need to invoke code in the UI thread you need to make the necessary UI thread invoke.

  • Return Type <string>

    • 0 - Void

    • 1 - Byte

    • 2 - Short

    • 3 - Int

    • 4 - Long

    • 5 - Float

    • 6 - Double

    • 21 - Char

    • 22 - String

    • 23 - Byte Array

Parameters

  • Type <Parameters Type>

    • 0 - Void

    • 1 - Byte

    • 2 - Short

    • 3 - Int

    • 4 - Long

    • 5 - Float

    • 6 - Double

    • 21 - Char

    • 22 - String

    • 23 - Byte Array

    • 101 - Activity - This option will pass the current Kalipso Form associated Android Activity.

    • 102 - View - This option allows you to select a Kalipso control and pass its top level Android View as a parameter.

    • 103 - Kalipso DB Accessor - This option will pass a KDBAccessor interface implementation for the specified database profile. This interface will allow you to access the specified database.

    • 104 - Android Context - Passes in a Context with assets/resources from the specified file (in this case it must be an APK file). This will be necessary if the APK uses its own resources.

    • 105 - PostNotify Interface - This option will pass a KExternalEventsInterface implementation. You can use this to send notifications back to Kalipso if you have asynchronous code executing in the library, or for example a background thread that you leave running. This will allow you to invoke the "App Notified" event in forms an fill in Temporary variables from that event. This invocations you make to notify Kalipso are asynchronous, so the calls to this interface will return immediatly, and they return false if no Form was found to handle the notification. This also allows you to register for event notification callbacks, like OnActivityresult, AppPausing, AppResuming, Key releated events, etc.

You can find the android java library containing the interfaces in Designer folder under "Plugins\Android\libs"

You can only call static Java functions with this, but you can inside dynamically create Java objects/classes. So you can just use the static methods as a Wrapper to invoke other Java code you have in the library. If you do this, don't forget to use LoadAPK to load the library and keep it attached. If you call RunAPK directly without a previous call to LoadAPK Kalipso will unload the JAR in the end and you will loose your objects to the garbage collector.

To add new Views to Kalipso Forms from your Java code, pass in a parameter of type 102-View and get its parent from Java. This will be an AbsoluteLayout where you can add your own controls. For example you can create an invisible Label in Kalipso to work as a placeholder, then pass that Label as a parameter to your library function, then you get the parent and get the LayoutParams so you can add a new control in the same position.

If you are using a JAR library, it needs to contain the classes.dex file for Android, but it is usually preferable to compile an APK for Android.

The library is loaded using Android DexClassLoader: https://developer.android.com/reference/dalvik/system/DexClassLoader

Android documentation quote: "A class loader that loads classes from .jar and .apk files containing a classes.dex entry. This can be used to execute code not installed as part of an application."

Last updated