Erel's help - phone contacts

slowtime

Active Member
Licensed User
Longtime User
Hi,
sorry if I posts twice but I think my old post is a wrong post.

Help me, please.

This code works correctly on my samsung Galaxy s 2.2 ONLY if I store contacts in Google ( phone let me choice beetwen store contacts in phone,in sim or in google ( for future sync I think). But I need store my contacts only in phone ( first privacy ) but so I can't use phonelib.

Thank you.


Sub Process_Globals

End Sub
Sub Globals
Dim EditText1 As EditText
Dim Button1 As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
EditText1.Initialize("") 'Need to call Initialize becuase views are added manually
Button1.Initialize("Button1")
Button1.Text = "Click me!"
activity.AddView(Button1, 10dip, 10dip, 200dip, 100dip)
Activity.AddView(EditText1, 10dip, 120dip, 300dip, 100dip)
End Sub
Sub Button1_Click
Dim Contacts As Contacts
Dim list1 As List
list1 = Contacts.GetAll
Dim listOfNames As List
listOfNames.Initialize
'Create a list with the contacts names
For i = 0 To list1.Size - 1
Dim c As Contact
c = list1.Get(i) 'fetch the Contact from the original list
If c.DisplayName.IndexOf("@") = -1 Then 'remove email only contacts
listOfNames.Add(c.DisplayName)
End If
Next
Dim res As Int
res = InputList(listOfNames, "Choose contact", -1)
If res <> DialogResponse.CANCEL Then
Dim name As String
name = listOfNames.Get(res)
Dim c As Contact
'find the original contact based on the chosen name
For i = 0 To list1.Size
c = list1.Get(i)
If c.DisplayName = name Then Exit
Next
If c.PhoneNumber.Length > 0 Then
EditText1.Text = c.DisplayName
Else
Dim m As Map
m = c.GetPhones
If m.Size > 0 Then
EditText1.Text = m.GetKeyAt(0)
Else
EditText1.Text = "N/A"
End If
End If
Dim PhoneNumber As String
PhoneNumber = EditText1.Text
End If
End Sub
 
Top