Skip to content

Android Improvements in Xojo 2023r3

Android remains in Beta, but there have been many fixes and improvements in Xojo 2023r3 and I’d like to highlight a few including: more support for dark mode, additions to MobileTextField, a Destination property, a HasBackButton property, MobilePopupMenu, enhancements to MobileHTMLViewer, support for running JavaScript, the new Kotlin Declare and more.

Although Xojo for Android does not yet have full dark mode support, things continue to head in that direction. Previously your app would adjust its UI for light/dark if the Support Dark Mode property was turned on in the Android Build Settings. Starting in Xojo 2023r3, Color.TextColor and Color.FillColor also adjust their values when run in light mode or dark mode, making it easier for your custom drawing to also adapt.

MobileTextField gets a couple new additions. The ReturnPressed event is now called when, as the name suggests, return is pressed. The AllowSpellChecking property is now also available for MobileTextField and MobileTextArea.

In the Shared Build Settings Inspector there is now a Destination property as there is with other platforms.

Many Android devices have physical back buttons and all let you turn on global software controls that have a back button, but sometimes you want to have the back button clearly shown on the navigation toolbar. With Xojo 2023r3, the new HasBackButton property of MobileScreen can show a back button on the navigation toolbar.

To make it easier to write code that is applicable to both iOS and Android, but not other platforms, there is a new TargetMobile constant available for conditional compilation.

MobilePopupMenu is an all-new control for Android that makes it possible to simplify some of your user interfaces. It works similarly to a PopupMenu on Desktop or Web: when the user taps this control a list of items appears and they can choose one.

On the Advanced tab of the Android Build Settings there is a new Manifest section with a Permissions property. Here you can specify the names of Android permission constants that are needed by Declares or libraries. They are added to the AndroidManifest.xml file when the app is run/built.

MobileHTMLViewer got several enhancements. It now has various processing events, including: DocumentBegin, DocumentComplete, CancelLoad, Error, NewWindow, DocumentProgressChanged and TitleChanged.

And there is now support for running JavaScript using the ExecuteJavaScript method along with the JavaScriptResult and JavaScriptRequest events. ExecuteJavaScript is asynchronous and results appear in the JavaScriptResult event. To call the JavaScriptRequest event, use xojo.execute() in the JavaScript code. A method name and up to 5 parameters can be passed back to Xojo. Learn more in the Xojo Programming Documentation.

The last thing I want to highlight is the new Kotlin Declare. For advanced users, this adds the ability to create Android declares that can pass untouched calls via Alias (with the exception of required type/object handling) to the Kotlin compilation step. This is done by specifying Lib “Kotlin” or adding “:Kotlin” to the end of Lib. Here are a couple examples of what this can look like:

Declare Function AndroidVersion Lib "Kotlin" Alias "android.os.Build.VERSION.RELEASE" As CString
Declare Sub findAllAsync Lib "Object:ctrl:MobileHTMLViewer:Kotlin" Alias "findAllAsync(myfind.toString())" (myFind As CString)

Of course there were many bug fixes as well. Be sure to check out the full release notes for all the details.

Paul learned to program in BASIC at age 13 and has programmed in more languages than he remembers, with Xojo being an obvious favorite. When not working on Xojo, you can find him talking about retrocomputing at Goto 10 and on Mastodon