Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8696467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:16:37+00:00 2026-06-13T01:16:37+00:00

I am pulling contact name and thumbnail by phone number with below method. When

  • 0

I am pulling contact name and thumbnail by phone number with below method.
When it runs GC goes mad. Methos is in a utility class and gets called from an adapter to populate a listview. List has more than 20 items/numbers to query contacts db.

I am new to Java and Android I can’t seem to figure out what is wrong, or if nothing is wrong how to optimize it.

Main problem is that listview is in a ViewPager and this make horizontal scrolling quite slow and jerky.

public static Contact getContact(Context ctx, String phoneNumber)
{
    String contactName = "";
    Long contactId= 0L;
    Bitmap contactPhoto =null;
    ContentResolver localContentResolver = ctx.getContentResolver();
    Cursor contactLookupCursor =  
       localContentResolver.query(
                Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, 
                Uri.encode(phoneNumber)), 
                new String[] {PhoneLookup.DISPLAY_NAME, BaseColumns._ID}, 
                null, 
                null, 
                null);
    try {
    while(contactLookupCursor.moveToNext()){
        contactName = contactLookupCursor.getString(contactLookupCursor.getColumnIndexOrThrow(PhoneLookup.DISPLAY_NAME));
        contactId = contactLookupCursor.getLong(contactLookupCursor.getColumnIndexOrThrow(BaseColumns._ID));
        Uri uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, contactId);
        InputStream input = ContactsContract.Contacts.openContactPhotoInputStream(ctx.getContentResolver(), uri);
        contactPhoto = BitmapFactory.decodeStream(input);
        }
    }
    finally {
    contactLookupCursor.close();
    } 

    return new Contact(contactName,contactId,contactPhoto);
}

Here is a sample from logcat

 10-16 22:05:39.745: D/dalvikvm(29171): GC_CO

NCURRENT freed 322K, 6% free 15200K/16071K, paused 1ms+11ms
10-16 22:05:40.005: D/dalvikvm(29171): GC_FOR_ALLOC freed 1428K, 12% free 14170K/16071K, paused 15ms
10-16 22:05:40.080: D/dalvikvm(29171): GC_CONCURRENT freed 70K, 12% free 14303K/16071K, paused 1ms+8ms
10-16 22:05:40.230: D/dalvikvm(29171): GC_CONCURRENT freed 305K, 10% free 14476K/16071K, paused 2ms+1ms
10-16 22:05:40.315: D/dalvikvm(29171): GC_EXPLICIT freed 169K, 11% free 14348K/16071K, paused 4ms+12ms
10-16 22:05:40.660: D/dalvikvm(29171): GC_CONCURRENT freed 329K, 10% free 14495K/16071K, paused 1ms+3ms
10-16 22:05:40.850: D/dalvikvm(29171): GC_CONCURRENT freed 543K, 11% free 14416K/16071K, paused 1ms+1ms
10-16 22:05:40.980: D/dalvikvm(29171): GC_CONCURRENT freed 380K, 10% free 14497K/16071K, paused 1ms+4ms
10-16 22:05:41.135: D/dalvikvm(29171): GC_CONCURRENT freed 521K, 11% free 14440K/16071K, paused 2ms+2ms
10-16 22:05:41.375: D/dalvikvm(29171): GC_CONCURRENT freed 406K, 11% free 14444K/16071K, paused 1ms+2ms
10-16 22:05:41.470: D/dalvikvm(29171): GC_CONCURRENT freed 270K, 10% free 14583K/16071K, paused 2ms+2ms
10-16 22:05:41.680: D/dalvikvm(29171): GC_CONCURRENT freed 290K, 9% free 14774K/16071K, paused 2ms+4ms
10-16 22:05:41.760: D/dalvikvm(29171): GC_EXPLICIT freed 98K, 9% free 14749K/16071K, paused 3ms+2ms
10-16 22:05:41.900: D/dalvikvm(29171): GC_CONCURRENT freed 199K, 7% free 14973K/16071K, paused 1ms+3ms
10-16 22:05:42.070: D/dalvikvm(29171): GC_CONCURRENT freed 277K, 7% free 15086K/16071K, paused 1ms+3ms
10-16 22:05:42.335: D/dalvikvm(29171): GC_CONCURRENT freed 416K, 6% free 15158K/16071K, paused 1ms+3ms
10-16 22:05:42.430: D/dalvikvm(29171): GC_CONCURRENT freed 1235K, 11% free 14315K/16071K, paused 1ms+2ms
10-16 22:05:42.525: D/dalvikvm(29171): GC_CONCURRENT freed 452K, 11% free 14364K/16071K, paused 2ms+3ms
10-16 22:05:42.925: D/dalvikvm(29171): GC_CONCURRENT freed 371K, 11% free 14445K/16071K, paused 2ms+1ms
10-16 22:05:43.045: D/dalvikvm(29171): GC_CONCURRENT freed 495K, 11% free 14335K/16071K, paused 2ms+2ms
10-16 22:05:43.190: D/dalvikvm(29171): GC_CONCURRENT freed 295K, 11% free 14431K/16071K, paused 2ms+3ms
10-16 22:05:43.315: D/dalvikvm(29171): GC_EXPLICIT freed 236K, 11% free 14329K/16071K, paused 2ms+3ms
10-16 22:05:43.575: D/dalvikvm(29171): GC_CONCURRENT freed 316K, 11% free 14436K/16071K, paused 1ms+1ms
10-16 22:05:43.660: D/dalvikvm(29171): GC_CONCURRENT freed 281K, 10% free 14585K/16071K, paused 1ms+2ms
10-16 22:05:43.905: D/dalvikvm(29171): GC_CONCURRENT freed 309K, 9% free 14754K/16071K, paused 2ms+3ms
10-16 22:05:44.070: D/dalvikvm(29171): GC_CONCURRENT freed 270K, 7% free 14968K/16071K, paused 2ms+2ms
10-16 22:05:44.300: D/dalvikvm(29171): GC_CONCURRENT freed 265K, 7% free 15103K/16071K, paused 1ms+4ms
10-16 22:05:44.495: D/dalvikvm(29171): GC_CONCURRENT freed 400K, 6% free 15176K/16071K, paused 2ms+5ms
10-16 22:05:44.695: D/dalvikvm(29171): GC_CONCURRENT freed 447K, 6% free 15137K/16071K, paused 3ms+6ms
10-16 22:05:44.780: D/dalvikvm(29171): GC_EXPLICIT freed 354K, 7% free 15037K/16071K, paused 2ms+3ms
10-16 22:05:45.075: D/dalvikvm(29171): GC_CONCURRENT freed 422K, 7% free 15104K/16071K, paused 1ms+2ms
10-16 22:05:45.140: D/AbsListView(29171): Get MotionRecognitionManager
10-16 22:05:45.340: D/dalvikvm(29171): GC_CONCURRENT freed 293K, 6% free 15252K/16071K, paused 2ms+6ms
10-16 22:05:45.340: D/AbsListView(29171): [unregisterDoubleTapMotionListener]
10-16 22:05:45.340: I/MotionRecognitionManager(29171):   .unregisterListener : / listener count = 0->0, listener=android.widget.AbsListView$4@41a600c8
10-16 22:05:45.530: D/dalvikvm(29171): GC_CONCURRENT freed 849K, 8% free 14799K/16071K, paused 2ms+7ms
10-16 22:05:45.720: D/dalvikvm(29171): GC_CONCURRENT freed 394K, 8% free 14908K/16071K, paused 3ms+5ms
10-16 22:05:45.940: D/dalvikvm(29171): GC_CONCURRENT freed 452K, 8% free 14845K/16071K, paused 2ms+3ms
10-16 22:05:46.085: D/dalvikvm(29171): GC_CONCURRENT freed 374K, 8% free 14917K/16071K, paused 1ms+3ms
10-16 22:05:46.335: D/dalvikvm(29171): GC_CONCURRENT freed 457K, 8% free 14892K/16071K, paused 1ms+2ms
10-16 22:05:46.390: D/dalvikvm(29171): GC_EXPLICIT freed 148K, 8% free 14870K/16071K, paused 1ms+3ms
10-16 22:05:46.550: D/dalvikvm(29171): GC_CONCURRENT freed 415K, 8% free 14844K/16071K, paused 2ms+4ms
10-16 22:05:46.680: D/dalvikvm(29171): GC_CONCURRENT freed 223K, 7% free 15046K/16071K, paused 2ms+3ms
10-16 22:05:46.825: D/AbsListView(29171): Get MotionRecognitionManager
10-16 22:05:46.965: D/dalvikvm(29171): GC_CONCURRENT freed 346K, 6% free 15124K/16071K, paused 1ms+3ms
10-16 22:05:46.965: D/AbsListView(29171): [unregisterDoubleTapMotionListener]
10-16 22:05:46.965: I/MotionRecognitionManager(29171):   .unregisterListener : / listener count = 0->0, listener=android.widget.AbsListView$4@41a49d90
10-16 22:05:47.095: D/dalvikvm(29171): GC_CONCURRENT freed 755K, 9% free 14758K/16071K, paused 2ms+5ms
10-16 22:05:47.375: D/dalvikvm(29171): GC_CONCURRENT freed 416K, 8% free 14835K/16071K, paused 2ms+5ms
10-16 22:05:47.565: D/dalvikvm(29171): GC_CONCURRENT freed 415K, 8% free 14888K/16071K, paused 2ms+5ms
10-16 22:05:47.975: D/dalvikvm(29171): GC_CONCURRENT freed 475K, 8% free 14814K/16071K, paused 2ms+3ms
10-16 22:05:48.105: D/dalvikvm(29171): GC_CONCURRENT freed 411K, 8% free 14867K/16071K, paused 2ms+3ms
10-16 22:05:48.155: D/dalvikvm(29171): GC_EXPLICIT freed 114K, 9% free 14760K/16071K, paused 2ms+4ms
10-16 22:05:48.280: D/dalvikvm(29171): GC_CONCURRENT freed 284K, 8% free 14902K/16071K, paused 1ms+3ms
10-16 22:05:48.435: D/dalvikvm(29171): GC_CONCURRENT freed 332K, 7% free 15000K/16071K, paused 3ms+4ms
10-16 22:05:48.655: D/dalvikvm(29171): GC_CONCURRENT freed 415K, 7% free 14985K/16071K, paused 1ms+2ms
10-16 22:05:48.805: D/dalvikvm(29171): GC_CONCURRENT freed 451K, 7% free 15002K/16071K, paused 3ms+5ms
10-16 22:05:49.150: D/dalvikvm(29171): GC_CONCURRENT freed 417K, 7% free 14985K/16071K, paused 1ms+2ms
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:16:38+00:00Added an answer on June 13, 2026 at 1:16 am

    You are iterating over an entire result set, creating bitmaps for all the thumbnails, then throwing all those results away except the last one. If you only want the last one, just process the last one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Pulling in info from a web scrape, I got this name: >> temp Rob
Can Magento view/manage our customers by their business name in addition to their contact
I am pulling me hair out about this one. http://www.nettunes.co.za/build/contact.php I have an image
Pulling my hair out over this one. I have one wordpress install at /2009
Pulling my hair out. I've got a table 'Belts' with columns 'BeltID' and 'BeltColor'.
im pulling in images from the net, and want to manipulate them a bit
Im pulling a text file - it will be input by user currently its
I've been pulling my hair out with this function. It's a function within a
I'm pulling my hair out here trying to get CSS to position only a
I am currently pulling an XML feed into a webapp through ajax. Obviously i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.