sms - list scroll lags for getting data from conversation in android -


i'm trying show sms conversation in android, purpose i've used following code , works fine.

uri sms_inbox = uri.parse("content://sms/conversations/"); cursor c = getcontentresolver().query(sms_inbox, null, null, null,                 "date desc"); 

for each item in list i've use:

string thread_id = cursor.getstring(cursor.getcolumnindexorthrow(staticfinalvalue.thread_id))                 .tostring(); conversationdetailscursor data = getconversation.showingthreadid(thread_id , context); 

showingthreadid() is:

conversationdetailscursor details = new conversationdetailscursor();  uri uri = uri.parse("content://sms/inbox"); string = "thread_id=" + thread_id;  cursor mycursor = getcursor(uri, , context);  // phone , name inbox uri if (mycursor.movetofirst())     getnameandnumber(mycursor , details , context); else {     // phone , name sent uri     uri = uri.parse("content://sms/sent");     = "thread_id=" + thread_id;     mycursor = getcursor(uri, , context);      if (mycursor.movetofirst()) {         getnameandnumber(mycursor , details , context);      } } mycursor.close();   return details; }  private static void getnameandnumber(cursor mycursor , conversationdetailscursor details , context context) {         string number;         string name = "";         number = mycursor.getstring(mycursor.getcolumnindexorthrow(staticfinalvalue.address))                 .tostring();          // use try catch because advertising number has name in         // default          try {             double.parsedouble(number);             uri uri1 = uri.withappendedpath(phonelookup.content_filter_uri,                     uri.encode(number));             cursor test = context.getcontentresolver()                     .query(uri1, new string[] { phonelookup.display_name },                             null, null, null);              if (test.getcount() > 0) {                 test.movetofirst();                  name = test.getstring(test                         .getcolumnindexorthrow(staticfinalvalue.display_name));             }              test.close();         } catch (exception e) {             name = number;         }           details.setname(name);         details.setnumber(number);        }      private static cursor getcursor(uri uri, string ,context context) {          return context.getcontentresolver().query(uri,                 new string[] { staticfinalvalue.address }, where, null, null);     } 

my problem code performance, specific list scroll lags periodically between swipes. reason data 3 defferent cursors.

one getting thread_id.

one getting phone of message inbox or send

and last checking phone number exists on phone book or not getting name , other thing

i see telephony.sms.conversations coming versions 19+.

main question: there better way load data ?

another way load , save data in background don't want use this.

my answer

i've improved performance multi threading, showing default value in list , getting data in thread, after call notifydatasetchanged() refreshing list data. i'd grateful if come better suggestion.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -