Automcomplete names and emails in keyserver tab

This commit is contained in:
Dominik Schürmann
2014-08-14 16:12:42 +02:00
parent 62f7bf6215
commit 9ad09a3982
3 changed files with 35 additions and 3 deletions

View File

@@ -234,6 +234,24 @@ public class ContactHelper {
return new ArrayList<String>(mails);
}
public static List<String> getContactNames(Context context) {
ContentResolver resolver = context.getContentResolver();
Cursor cursor = resolver.query(ContactsContract.Contacts.CONTENT_URI,
new String[]{ContactsContract.Contacts.DISPLAY_NAME},
null, null, null);
if (cursor == null) return null;
Set<String> names = new HashSet<String>();
while (cursor.moveToNext()) {
String name = cursor.getString(0);
if (name != null) {
names.add(name);
}
}
cursor.close();
return new ArrayList<String>(names);
}
public static Uri dataUriFromContactUri(Context context, Uri contactUri) {
Cursor contactMasterKey = context.getContentResolver().query(contactUri,
new String[]{ContactsContract.Data.DATA2}, null, null, null, null);