Page 1 of 1

Contacts on Android

Posted: Mon Jun 08, 2020 6:02 pm
by AGC studios
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.

Re: Contacts on Android

Posted: Tue Jun 09, 2020 1:04 pm
by simon.schvartzman
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

Re: Contacts on Android

Posted: Tue Jun 09, 2020 1:24 pm
by AGC studios
WOW, Thanks. :D :D :D Ill check it out.