autocomplete - Is there a limit in Android on number of email address from contacts that I can fetch? -



autocomplete - Is there a limit in Android on number of email address from contacts that I can fetch? -

i making android app when user starts typing email address, gets autocomplete suggestions phone contact book.

if set limit on code fetch 100 address, works fine. if don't set limit, app freezes. haven't tried set higher limit , see , point gives up.

how can optimize code?

private arraylist<string> getnameemaildetails() { arraylist<string> emlrecs = new arraylist<string>(); **int count = 0;** // additional hashset<string> emlrecshs = new hashset<string>(); context context = getbasecontext(); contentresolver cr = context.getcontentresolver(); string[] projection = new string[] { contactscontract.rawcontacts._id, contactscontract.contacts.display_name, contactscontract.contacts.photo_id, contactscontract.commondatakinds.email.data, contactscontract.commondatakinds.photo.contact_id }; string order = "case when " + contactscontract.contacts.display_name + " not '%@%' 1 else 2 end, " + contactscontract.contacts.display_name + ", " + contactscontract.commondatakinds.email.data + " collate nocase"; string filter = contactscontract.commondatakinds.email.data + " not ''"; cursor cur = cr.query(contactscontract.commondatakinds.email.content_uri, projection, filter, null, order); if (cur.movetofirst()) { { string emladdr = cur.getstring(3); // maintain unique if (emlrecshs.add(emladdr.tolowercase())) { emlrecs.add(emladdr); **count++;** // additional } } while (cur.movetonext() **&& count < 100**); } cur.close(); homecoming emlrecs; }

your app "freezes" because performing long-running or complicated calculations on ui thread. thread responsible drawing app's views , responding user input.

you should move requests (as network activity) thread maintain app becoming unresponsive.

look threads or asynctask address these restrictions.

android autocomplete

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -