Eia is also mimimally interoperable with Java.
It helps in scenarios where to access few runtime APIs that would otherwise require compiling new extensions or modification to the App Inventor source code.
Examples
- Using the Java string API to trim a Label's content
// trim Label1's Text and update
Label1.Text(Label1.Text().trim())
- Calling Android APIs to retrieve information
// returns package name of actvitiy that opened our application
// e.g. "android-app://com.sec.android.app.launcher"
let caller = screen.getReferrer().toString()
In the above example,
screen
is the current Activity object.
- Showing a custom toast with Android API
know android.widget.Toast
let toast = Toast.makeText(
screen, // context
"Hello, World!",
Toast.LENGTH_LONG
)
toast.setDuration(2000)
toast.show()