The Basics: How do I Create Hello World on Android?
This lesson describes the very basic steps of creating an application that runs on Android via LiveCode. Screen captures and sample code are provided.
The lesson bridges the gap between installing the Android development environment (covered in lessons: How do I Become an Android Developer on a Mac? and How do I Become an Android Developer on a PC?) and implementing the first LiveCode application that runs on an Android device. The code is very elementary and the steps are very detailed, focusing primarily on the mechanics of implementation and deployment.
Note: This lesson assumes that you have already installed and configured the necessary packages to begin developing software for the Android platform.
Open the LiveCode IDE and create a new mainstack by selecting File -> New Stack -> Default Size from the IDE panel. This creates an empty stack on which you will be implementing the application.
Right click on the mainstack window you created to open a dialog window, then select Stack Property Inspector from that dialog. Change the contents of the Name field from Untitled 1 to Hello World.
Select the button you just dropped onto the mainstack window and the Property Inspector changes to display the properties of the button. Change the Name of the button from Button to Click Me.
Right click on the button you just renamed and select Edit Script. The Script Editor window opens, allowing you to write the code that is to run on your Android application. Add the following code into the editor window:
on mouseUp answer "Hello World!" with "Ok" end mouseUp
Then select the Apply button. You have now implemented your Android application and are ready to launch it on an Android device.
In this lesson we are using the emulator to simulate an Android device. Launch the Android emulator from your Android SDK and AVD Manager. Lessons: How do I Become an Android Developer on a Mac? and How do I Become an Android Developer on a PC? would have shown you how to configure and start your simulated Android device.
Note: The emulator needs to be running for LiveCode to launch your application.
Select File -> Standalone Application Settings ... from the IDE Panel. This launches the Standalone Application Settings dialog. Select Android as your target and ensure that the Build for Android tick box is selected. You should be able to use the default settings.
The last step is to select the deployment target from Deployment -> Test Target. You should be able to select the emulator that is already running. This enables the Test button that launches your application into the Android emulator.