Add phone functionality to the app
You can generate the code to interact with the mobile device's features. This example shows how to call a selected phone number from the app.
- Open the appflow.4ba file.
- Right-click on the BA diagram and select New > Phone.
-
Right-click on the Form entity and select Add
Relation. Click on the Form entity again and drag the
Relation arrow to the Phone entity.
-
Select the Relation between the Form and the
Phone entity and set the
Action
property to callContact. Set thePhone Number
property to the phone column (account.phone
in our example database). - Save your changes to appflow.4ba.
-
Double-click on the Form entity to open it in Form Designer. Add a
button that triggers your
callContact
action.- Expand the canvas and the grid that is containing the form fields if you need room to add a button.
- Select Widget > Button from the menu.
-
Draw a button onto your form. Set the
name
property of your button tocallContact
. The name of the button is also the action to be triggered by the button. -
Set the
text
property of the button to Call Contact.
- To preview your form, select Build > Preview.
- Make further changes to your form if you wish.
- Save your changes to the form.
- Execute your program, this will rebuild your program and execute it in one step.
-
Test the new button.
Tip: The sample data in the phone field is not a valid phone number. Run the app and select Modify to update the phone field with a phone number of your choice. On the Android emulator, the MENU button displays the available program actions.