B4A Library New library TGetContacts to get all contacts

Hello,

This is my first library to get all contacts' name and phone number. A list is returned with contact's name and address, separated by newline.

Needs android.permission.READ_CONTACTS. Add the following line in Manifest file:
AddPermission("android.permission.READ_CONTACTS")

Copy the TGetContacts.jar, TGetContacts.xml in Basic4android's Libraries folder. Example project for Basic4android is attached.

Example:

Dim TC As TGetContacts
Dim ContactList As List

ContactList.Initialize

ContactList.AddAll(TC.GetAllContacts) 'Retrieve all contacts. Each list item is a string of Name and Phonenumber - newline separated.


Tested on Android SDK emulator android version 2.2, and on a real device with android 2.3.

Best regards.
 

Attachments

  • Example_TGetContacts.zip
    309.3 KB · Views: 732
  • LibTGetcontacts.zip
    3.3 KB · Views: 666
Last edited:

bsnqt

Active Member
Licensed User
Longtime User
@rabiuls:

Thank you very much for your sharing, it is very useful for us. It reads the contacts and phones very fast.
 
Last edited:

rabiuls

Member
Licensed User
Longtime User
Getting contacts

@bsnqt, I am happy to know that you found it useful :).

Best regards.
 

bsnqt

Active Member
Licensed User
Longtime User
@bsnqt, I am happy to know that you found it useful :).

Best regards.

It is true. Although till now I am the only person who say it out, but I think there are many other members use it and also find it useful, but they may be too busy to write it out here. Or they may not need it at this moment, however they may use it later on. Once again thanks for sharing. I am happy being in this forum having people like you to share and help us.

I am learning to create my very first library using Eclipse so I would appreciate if you can teach me how to do your library. Surely I have already looked at the library tutorial but it is too general for me. I am more interested in communication libraries with phone / call / sms functions etc. but I used to do them only with .NET and C#, Visual Basic so I am still a dummy in Java and Eclipse.

Regards,
 
Last edited:

rabiuls

Member
Licensed User
Longtime User
Well, bsnqt, the library is not such a big deal or something big, that has to be mentioned. It's a tiny one, honestly. I also download and use many libraries without making any comments - lurker. But thanks, ha ha ha.


Like you I am also new and trying to understand the working system of B4A with eclipse. It may need some time. Since B4A is very good for writing something quickly, I think it is also good to know about how it works with eclipse, since that one is supported by google officially.

By the way, I am attaching the eclipse source code here for you or anyone who may need it. Make it according to the video tutorial - for creating library.

[ You could use JD-GUI to take a look without asking ;) ]

Best regards.
 

Attachments

  • TGetContacts-src-eclipse-project.zip
    5.7 KB · Views: 261

bsnqt

Active Member
Licensed User
Longtime User
I agree totally with you :)

Thanks again for sharing the library code, I will use it as a lesson / starting point to learn :)

Best regards,

bsnqt
 

rabiuls

Member
Licensed User
Longtime User
One thing that might help you to get started with eclipse is the youtube lessons here:

Android Tutorial & Lessons 1: Installing Eclipse and SDKs - YouTube

As a newbie to Java+Android+Eclipse this site was very helpful for me. The above link is lesson 1. You would find 25-30 lessons there. I think after watching 7 to 8 videos you will be able to make an app with eclipse. Which would help later to make library for B4A. The person and his presentation/teaching style is very good. After making the tutorials he left the channel and made another account on youtube with 200 tutorials. His new account link:

thenewboston - YouTube

And his website (here the 200 videos are serially placed and can be watched) is List of Videos for Android Application Development

The videos are also available on torrent site. See his first videos on youtube, at first.

Then try to make an activity on eclipse, and call it from B4A for result :).

Best of luck.
 

JJM

Active Member
Licensed User
Longtime User
Hello,
I'll would like to get name and EMail. Is it possible?

Thank you

JJ M
 

rabiuls

Member
Licensed User
Longtime User
Hello,
I'll would like to get name and EMail. Is it possible?

Thank you

JJ M

Hello,
This is not possible with TGetContacts. It only retrieves name and phone number.

You can get the email address by "Name". Use phone library and the command "Contacts2.FindByName" to get the email address. There is an example in the phone library's documentation.

Thank you.
 

PhilipK

Member
Licensed User
Longtime User
This is a direct way of getting the contacts into a list. Great, thanks.
The list appears to be ordered by phone number which makes it difficult to read/find a name.
Is there a way of ordering it by name?
 

Humberto

Active Member
Licensed User
Longtime User
I´m new and I read just today.
To order by name just add this line " ContactList.SortCaseInsensitive(True) " like bellow

ContactList.AddAll(TC.GetAllContacts) 'Retrieve all contacts. Each list item is a string of Name and Phonenumber - newline separated.
ContactList.SortCaseInsensitive(True)
result = InputMultiList(ContactList, "Select contact") 'Allow user to select necessary contact.

Thanks for the library
 

onimatsu

Member
Licensed User
Longtime User
A little question.. If i press ok without checked a contact, there is a error in java. How i can delete this error on the code??
And if i want use only input list and not input multi list, how i must change the code??
Thanks
 

Gerrard

Member
Licensed User
Longtime User
Dear Rabiuls
I have used your library successfully and get ALL contacts with their landline phone numbers and mobile phone numbers. How can I get ONLY contacts that have mobile numbers?
 
Top