This document is a step-by-step explanation of how to create a simple Android application with GeneXus using Ruby and SQLServer. If you are using another generator (.NET, Java) or DBMS, the steps are the same even though the prerequisites change.
Before starting the following steps, please check that the Android Requirements are correctly installed. See Android platform for more information.
After following this step-by-step guide, the following application should be obtained:
Then, it can be improved for a great look & feel.
Create a New Knowledge Base and select Ruby as Prototyping Language (you can use .NET Generator or Java Generator).
Create a Customer and Company transaction with the following structure:
Note the Domains with Special Semantics in Phone, Email, Address attributes. In both cases use autonumber in the identifier attribute. While positioned in the CustomerId field, press F4 to see its properties, and change the Autonumber property to True. Do the same for the CountryId attribute.
Apply Work With for Smart Devices pattern to both transactions. For example, open each transaction, click on the Patterns selector, choose the Work With for Smart Devices tab, and select the checkbox as shown below. Next, click on Save:
From the Toolbox, drag & drop the control Attribute/variable to insert the attributes you want to see on the Customer list screen (for ex. CustomerEmail):
To remove the attribute label, change the Label position property value to "None":
Create a Menu object called, for example, Menu.
This object is like a menu; you can use it to call the Work With objects created in the previous Step. To do so, right-click on the Items option to add actions to the dashboard. Add an action for each Work With. You must select the WorkWithDevicesCustomer in the Select Object dialog that displays them for the first work with, and do the same for the second one, choosing WorkWithDevicesCompany:
When you select a WorkWithDevices <TransactionName> object, the Event associated with this action will be generated automatically:
Event 'WorkWithDevicesCustomer'
WorkWithDevicesCustomer.Customer.List()
EndEvent
Event 'WorkWithDevicesCompany'
WorkWithDevicesCompany.Company.List()
EndEvent
Edit the SmartDevices Generator Preferences. Make sure you have set the following properties:
- Generate Android: True (default)
- Generate BlackBerry: False
- Generate iOS: False
- Main Platform: Android
- Android SDK directory: Select your Android SDK directory (that is: the directory where you have installed the program)
- JDK Directory: Select your JDK directory.
Press F5 to build the application. The first time you do it, GeneXus needs to know the database connection information. This may help too: First Ruby Model
The other possibility is to deploy to cloud.
The following output is shown, as well as the Impact Analysis report, indicating the tables that must be created in the database. Click on the Create button to create them.
Then, GeneXus automatically runs your default web browser and the Android Emulator:
so you are ready to test both applications (web and SD).
Through the Development Menu opened in your browser, insert some companies and customers (in that order):
Now, wait until the Android emulator starts running the application. The first time it may take longer because the emulator Starts the Android OS:
After that, the application starts:
And you can test it!
To easily run your application directly on your Android device, see Executing From QR Codes
Enjoy it!
Note: To display an image for each menu action, go to the corresponding dashboard object created in step 4. Next, positioned on each action, associate the image (inserting simultaneously in the KB) through the properties dialog:
- To simplify the prototyping process, we recommend not to close the emulator between runs.
- This link is another tutorial with some additional help for troubleshooting (Spanish only).
To import GeneXus objects used in this demo, right on your KB, download the following file: My First Android Model
For more information, read Android - FAQ and Common Issues