Contacts on Android

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
AGC studios
Posts: 21
Joined: Thu Apr 23, 2020 1:49 pm

Contacts on Android

Post by AGC studios » Mon Jun 08, 2020 6:02 pm

So, I have a problem...

I'm trying to get a contact number on android using

Code: Select all

mobileGetContactData

Code: Select all

mobilePickData
But I cannot seem to be able to get the phone number but I can get the name... I looked at every thread and none of them seemed to have an answer... I hope they fixed it... (running LC 9.6 DP 4) (Android 9.0 Pie)
:( :(

here's my code:

Code: Select all

on mouseUp
   mobilePickContact 
   put the result into tID
   put mobileGetContactData (tID) into tData
   answer tData[phone]["mobile"]  -- I also tried    answer tData["mobile"] and using CAPS - didn't work.
end mouseUp
this is for the first name

Code: Select all

on mouseUp
   mobilePickContact 
   put the result into tID
   put mobileGetContactData (tID) into tData
   answer tData ["firstname"]
end mouseUp

Thanks.

simon.schvartzman
Posts: 665
Joined: Tue Jul 29, 2014 12:52 am

Re: Contacts on Android

Post by simon.schvartzman » Tue Jun 09, 2020 1:04 pm

Hi, I guess you are missing one dimension of the phone numbers array. The code below works fine for me. Hope it helps.

Code: Select all

on mouseUp
   mobilePickContact -- let user choose a contact
   put the result into tID -- LC returns an ID number
   if tID is empty then
      exit to top
   end if

   put mobileGetContactData(tID) into tData -- store the array in a variable
   put the keys of tData into aux
   
   repeat with x = 1 to the number of lines of aux
      switch the line x of aux
         case "phone"
            addPhones tData
            break
         case "address"
            addAddress tData
            break
         case "email"
            addemail tData
            break
      end switch
end mouseUp

Code: Select all

command addPhones tData
   put "mobile,iphone,main,home,work,other" into tPossNumberTypes
   repeat with x = 1 to 6
      put item x of tPossNumberTypes into tType
      if not(tData["phone"][tType][1] is empty) then
         put field "ContactData"  of card "ListCard" & tType & " number" & CR & ">  " & tData["phone"][tType][1] & CR into field "ContactData" of card "ListCard"
      end if
   end repeat
end addPhones
note: there maybe some errors because I took the code from a larger piece but I guess is good enough to get the idea.

Best
Simon
________________________________________
To ";" or not to ";" that is the question

AGC studios
Posts: 21
Joined: Thu Apr 23, 2020 1:49 pm

Re: Contacts on Android

Post by AGC studios » Tue Jun 09, 2020 1:24 pm

WOW, Thanks. :D :D :D Ill check it out.

Post Reply