首页 > 其他分享 >确定号码在不在联系人当中

确定号码在不在联系人当中

时间:2023-06-20 22:07:45浏览次数:31  
标签:cur 号码 联系人 number Uri 当中 null PhoneLookup String

public boolean contactExists(Context context, String number) { 
/// number is the phone number 
Uri lookupUri = Uri.withAppendedPath( 
PhoneLookup.CONTENT_FILTER_URI,  
Uri.encode(number)); 
String[] mPhoneNumberProjection = { PhoneLookup._ID, PhoneLookup.NUMBER, PhoneLookup.DISPLAY_NAME }; 
Cursor cur = context.getContentResolver().query(lookupUri,mPhoneNumberProjection, null, null, null); 
try { 
   if (cur.moveToFirst()) { 
      return true; 
} 
} finally { 
if (cur != null) 
   cur.close(); 
} 
return false; 
}

标签:cur,号码,联系人,number,Uri,当中,null,PhoneLookup,String
From: https://blog.51cto.com/u_16166892/6525360

相关文章