Action: ADD_TO_CONTACT

ADD_TO_CONTACT action adds the contact to the contact list. If your app wants to add or update the device’s contact list, then this action is to be called.

Attributes Value Mandatory
action_name ADD_TO_CONTACT Yes
event_list comma separated list of events, eg: TAP Yes
target_parameter_list comma separated list of attributes. This is optional if different from input_parameter_list. No
input_parameter_list comma separated list of parameters. See List of attributes for contact list application Yes

Note

  • Call this action with a target_parameter_list that contains attributes known to the contact list.
  • The comma separated parameters in the target_parameter_list must match the field names that the contact list understands. See List of attributes for contact list application
  • Add the user permission in the AndroidManifest.xml (For Android Only)
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>

Example

In this example, the user enters the contact info to add. On tap of PUSHBUTTON the device phone application is invoked. The contact info is added to the contact list.

<control type="TEXT" x="2" y="34" width="30" height="8" appearance_name="black" data_type="VARCHAR"
            default_value="Phone" keyboard_type="PHONE"/>
<control type="EDIT" x="35" y="34" width="60" height="8" appearance_name="edit_box" data_type="VARCHAR"
        field_name="phone_no_to_add" size="80" keyboard_type="PHONE"/>
<control type="PUSHBUTTON" x="35" y="44" width="60" height="8" appearance_name="blue_button" data_type="VARCHAR"
            default_value="ADD_TO_CONTACT">
            <actions>
                    <action event_list="TAP" action_name="ADD_TO_CONTACT"
                            target="" input_parameter_list="name,phone_no_to_add" target_parameter_list="display_name, work_phone"/>
    </actions>
    </control>

The figure on left shows the form where the user enters the information. On tapping the ADD_TO_CONTACT button, the contact app is invoked. The image shown below is generated from Android Simulator.

../_images/add_tocontact.png ../_images/add_tocontact1.png

iOS

On tapping the ADD_TO_CONTACT button, the contact app is invoked and All Contacts screen is displayed. Tapping on Cancel will bring you back to the your app. To check the contact details, you will have to open your Contacts app and tap on the contact you added. You will see the name and phone number displayed as per the user data added.

../_images/ios_addtocontactform.png ../_images/ios_contactinfo.png

Reference tutorial

This chapter uses source code from appemble-tutorial-actions. If you have not downloaded tutorial source code, click on Download Source Code - Tutorials

Android - Right click on appemble-tutorial-actions and click on Run as Android application.

iOS - Select scheme appemble-tutorial-actions and iPhone x.x simulator. Click on Product -> Run.

Good Read

ADD_FROM_CONTACT