Best practice for displaying Android contacts + phone numbers

What is the best performance approach to show a ListView with contacts and their phone numbers?

  • Use the CursorAdapter with the contact cursor and query for phone numbers when calling bindView for each row.
  • Copy all the contacts and phone numbers to an in-memory array in the background stream, and then show them using the ArrayAdapter.
  • Other solutions?
+7
source share
4 answers

In my opinion, the solution to the mixture should be better. Why is this? Because you do not know or believe that in most contexts you cannot know how and how many contacts you will need the application to display . Also, how many contacts are stored on the phone. If we know both answers, we can certainly make the most appropriate decision.

So, I suggest you first bring a fixed number of contacts, using an array in memory in the background thread, for example the first 20. Also, if you think that your application will make more than one request to this service. it will be awesome to use some kind of caching. The worst approach should be to call the contact service again and again. Then, to request contact 21, you can enter the following 20, and so on.

Thus, you can take advantage of both worlds and minimize disadvantages. It always depends on the application and the context we are talking about.

+1
source

I think this will depend on three factors:

  • How many contacts are we talking here?
  • How long does it take to load each contact? (For example, do you have a very complicated view that needs to be inflated, or do you get contact images / etc that require some kind of network I / O?)
  • How many contacts are displayed to the user at one time?

Your solution will suit most cases, although the second solution also offers some advantages:

Solution 1:

Advantage:

  • A delayed view of inflation in the “view as you go” view may work well when it is fast enough to inflate views without any noticeable user interface crashes.

Disadvantage:

  • If your contacts are connected with a lot of data and require some complication of inflation, you may notice a delay.

  • Less flexible and extensible compared to solution 2. As described below.

Solution 2:

Advantage:

  • You have control over all the stages, so you can easily simulate it as simple as one, but adding things can be easier: searching through the entire memory, selective sorting by array, etc. they work better when you have all the request for an array that already exists. Or, if you want to do a custom download later or add some more contact information that needs additional processing (such as network I / O), this might be a little easier than a cursor adapter.

Disadvantage:

  • Execution: This is not a textbook. making things more ordinary, you will need to handle all threads well and handle the initial look well. Make sure it scales.

So, depending on what exactly you work, select the appropriate one.

+1
source

I think http://www.higherpass.com/Android/Tutorials/Working-With-Android-Contacts/ would be an option. Where you can find all the objects you want ...

0
source

I think CursorAdapter is the best solution.

Also make sure that you watch this video http://www.youtube.com/watch?v=wDBM6wVEO70 It talks about the optimization, which, in my opinion, is necessary for your list to scroll smoothly.

0
source

All Articles