Skip to content

Instantly share code, notes, and snippets.

@webserveis
Last active December 4, 2020 10:00
Show Gist options
  • Save webserveis/1252bbe2a1fb5f63206240aaa3114bf8 to your computer and use it in GitHub Desktop.
Save webserveis/1252bbe2a1fb5f63206240aaa3114bf8 to your computer and use it in GitHub Desktop.
namespaces contacts group

Nombres de espacios

Dependiendo de donde se encuentra el contacto, sim, dispositivo, cuenta email, whatsapp, telegram...

Contactos en el dispositivo

Contactos del telefono

  • Global com.android.localphone
  • Samsung Galaxy Alpha vnd.sec.contact.phone
  • Sony Xperia com.sonyericsson.localcontacts

Contactos en la sim

  • Sim vnd.sec.contact.sim
  • Sony Xperia com.sonyericsson.adncontacts
  • Samsung Galaxy Alpha vnd.sec.contact.sim

Cuentas de contacto

Google contacts com.google

Aplicaciones de mensajeria

  • Whatsapp com.whatsapp
  • Telegram org.telegram.messenger
  • Facebook Messenger com.facebook.orca
  • Facebook Messenger lite com.facebook.mlite
  • Viber com.viber.voip
  • Line jp.naver.line.android
  • WeChat com.tencent.mm
  • Google Duo com.google.android.apps.tachyon
  • Google Allo com.google.android.apps.fireball

Funciones

getListAccountType para obtener las cuentas con contactos, phone, google, whatsapp... devuelve un array clave:valor con <tipo,nombre>

Resources

https://stackoverflow.com/questions/13472951/get-both-sim-numbers-in-a-dual-sim-android-phone

if (c != null) {
if (c.getCount() > 0) {
Log.i(TAG, "Total contacts: " + c.getCount());
while (c.moveToNext()) {
String[] columnNames = c.getColumnNames();
Log.i(TAG, "====================: ");
for (String columName : columnNames) {
int index = c.getColumnIndex(columName);
String value = c.getString(index);
Log.d(TAG, "columName: " + columName + " =" + value);
}
}
}
int contactNameColumn = c.getColumnIndex(ContactsContract.RawContacts.DISPLAY_NAME_PRIMARY);
c.close();
}
public static HashSet<AccountTypeModel> getListAccountType(Context context) {
HashSet<AccountTypeModel> accountTypes = new HashSet<>();
final Uri PROVIDER_URI = ContactsContract.RawContacts.CONTENT_URI;
final String[] PROJECTION = new String[]{
ContactsContract.RawContacts.ACCOUNT_TYPE,
ContactsContract.RawContacts.ACCOUNT_NAME};
Cursor c = context.getContentResolver().query(PROVIDER_URI, PROJECTION, null, null, null);
if (c != null) {
if (c.getCount() > 0) {
if (c.moveToFirst()) {
do {
accountTypes.add(new AccountTypeModel(
c.getString(c.getColumnIndex(ContactsContract.RawContacts.ACCOUNT_TYPE)),
c.getString(c.getColumnIndex(ContactsContract.RawContacts.ACCOUNT_NAME))
));
} while (c.moveToNext());
}
}
c.close();
}
return accountTypes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment