Back

ChooseContact

JS Py
Hello World

ChooseContact opens the Contacts app so that the user can select the name and either the phone number or email address of a user.

app.ChooseContact( type, callback )

Example - Choose Phone Number

function OnStart()
{
    lay = app.CreateLayout( "linear", "VCenter,FillXY" );

    btnChoose = app.CreateButton( "Choose Phone", 0.5, 0.1 );
    btnChoose.SetOnTouch( btnChoose_OnTouch );
    lay.AddChild( btnChoose );

    app.AddLayout( lay );
}

function btnChoose_OnTouch()
{
    app.ChooseContact( "phone", OnPhoneChoose );
}

function OnPhoneChoose( name, number )
{
     app.ShowPopup( name + " " + number );
}
from native import app

def OnStart():
    lay = app.CreateLayout( "linear", "VCenter,FillXY" )

    btnChoose = app.CreateButton( "Choose Phone", 0.5, 0.1 )
    btnChoose.SetOnTouch( btnChoose_OnTouch )
    lay.AddChild( btnChoose )

    app.AddLayout( lay )

def btnChoose_OnTouch():
    app.ChooseContact( "phone", OnPhoneChoose )

def OnPhoneChoose( name, number ):
    app.ShowPopup( name + " " + number )
    Copy     Copy All       Run      

Example - Choose Email Address

function OnStart()
{
    lay = app.CreateLayout( "linear", "VCenter,FillXY" );

    btnChoose = app.CreateButton( "Choose Email", 0.5, 0.1 );
    btnChoose.SetOnTouch( btnChoose_OnTouch );
    lay.AddChild( btnChoose );

    app.AddLayout( lay );
}

function btnChoose_OnTouch()
{
    app.ChooseContact( "email", OnEmailChoose );
}

function OnEmailChoose( name, email )
{
     app.ShowPopup( name + " " + email );
}
from native import app

def OnStart():
    lay = app.CreateLayout( "linear", "VCenter,FillXY" )

    btnChoose = app.CreateButton( "Choose Email", 0.5, 0.1 )
    btnChoose.SetOnTouch( btnChoose_OnTouch )
    lay.AddChild( btnChoose )

    app.AddLayout( lay )

def btnChoose_OnTouch():
    app.ChooseContact( "email", OnEmailChoose )

def OnEmailChoose( name, email ):
    app.ShowPopup( name + " " + email )
    Copy     Copy All       Run      
String: “Phone” or “Email”
function( name, data )