was wondering how you've missed that ;-)

On Wednesday, July 31, 2013 3:18:28 PM UTC+3, Kristopher Micinski wrote:
>
> Heh, this is also a good point, I was dumb not to point the OP in that 
> direction sooner :-) 
>
>
> On Wed, Jul 31, 2013 at 2:59 AM, Piren <[email protected] <javascript:>> 
> wrote: 
> > what the hell? why are you scanning the entire DB and in such a bad 
> fashion? 
> > You do know that the reason there's a ContentResolver is for you to run 
> > queries right? 
> > 
> > 
> http://developer.android.com/reference/android/provider/ContactsContract.PhoneLookup.html
>  
> > 
> > You'll get the result instantly. 
> > 
> > 
> > On Tuesday, July 30, 2013 9:27:49 PM UTC+3, shiva pendem wrote: 
> >> 
> >> HI everyone, 
> >> 
> >> 
> >> i am making an application to get the name of the contact no saved on 
> the 
> >> mobile. 
> >> 
> >> i am using the following code 
> >> 
> >> private class CallStateListener extends PhoneStateListener { 
> >> private String displayContacts(String incomingNumber) { 
> >>     ContentResolver cr = ctx.getContentResolver(); 
> >>        Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, 
> >>                null, null, null, null); 
> >>        if (cur.getCount() > 0) { 
> >>         while (cur.moveToNext()) { 
> >>         String id = 
> >> cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID)); 
> >>         String name = 
> >> 
> cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); 
> >>         if (Integer.parseInt(cur.getString( 
> >> 
> >> cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) { 
> >>                     Cursor pCur = cr.query( 
> >>                     ContactsContract.CommonDataKinds.Phone.CONTENT_URI, 
> >>                     null, 
> >>                     ContactsContract.CommonDataKinds.Phone.CONTACT_ID 
> +" = 
> >> ?", 
> >>                     new String[]{id}, null); 
> >>                     while (pCur.moveToNext()) { 
> >>                     String phoneNo = 
> >> 
> pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
>  
>
> >>                     if(phoneNo.length()>9&&incomingNumber.length()>9) 
> >>                     { 
> >>                     // 
> >> Log.v("Test",phoneNo.substring(phoneNo.length()-10,phoneNo.length())+" 
> >> 
> "+incomingNumber.substring(incomingNumber.length()-10,incomingNumber.length()));
>  
>
> >> 
> >> 
> if(phoneNo.substring(phoneNo.length()-10,phoneNo.length()).equals(incomingNumber.substring(incomingNumber.length()-10,incomingNumber.length())))
>  
>
> >>                     { 
> >>                     Toast.makeText(ctx, "Name: " + name + ", Phone No: 
> " + 
> >> phoneNo, Toast.LENGTH_SHORT).show(); 
> >>                     Log.v("Test","qualified   "+phoneNo+"   "+name); 
> >>                     pCur.close(); 
> >>                     return ""+name; 
> >>                     } 
> >>                     } 
> >>                     } 
> >>              pCur.close(); 
> >>          } 
> >>         } 
> >>        } 
> >>        return ""; 
> >>    } 
> >> i am calling the displayContacts() method with the incoming call no as 
> >> argument 
> >> but its taking about 18 to 29 seconds to get the contact name, some 
> times 
> >> it is taking more than 35 seconds, 
> >> 
> >> can any one suggest me the best way to get the contact names saved in 
> the 
> >> mobile, 
> >> i need to get the contact name in the following manner, 
> >> i have a contact with name as service call and no as 9848012345 
> >> and if i get a call i should get the name in not more than 5 seconds . 
> >> 
> >> if there are any new mechanisms that are used to implement this 
> mechanism 
> >> plese send me the links, 
> >> 
> >> Thanks 
> >> Shiva Shankar, 
> > 
> > -- 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Android Developers" group. 
> > To post to this group, send email to 
> > [email protected]<javascript:> 
> > To unsubscribe from this group, send email to 
> > [email protected] <javascript:> 
> > For more options, visit this group at 
> > http://groups.google.com/group/android-developers?hl=en 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Android Developers" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to [email protected] <javascript:>. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to