Why does Android Contact modify have a side effect of created an (Unknown) contact entry?
Date : March 29 2020, 07:55 AM
will be helpful for those in need There was an errant newInsert() call for the RAW_CONTACT_ID as part of the larger function which was causing the problem. Sorry for the time wasting question.
|
Android: Adding ringtone to contact doesn't work on a contact I just added, but works on a contact I added on previous s
Date : March 29 2020, 07:55 AM
Does that help Found an answer to my question. I should ask SO questions sooner, it seems as soon as I ask it the answer comes to me, even if I was working on the issue for days. Anyways, here is what is going on: the ringtoneSync method is looking for a rawContactId, which is created when you do the addContact() method. Problem is, the rawContactId is not committed until you call batchOperation.execute(). if(rawContactId != 0) {
if(!contact.isDeleted()) {
Log.e("SYNCING CONTACTS", "Updating " + username);
updateContact(context, resolver, account, contact, rawContactId, batchOperation);
ringtoneSync(resolver, username, context);
}
else {
Log.e("SYNCING CONTACTS", "Deleting " + username);
deleteContact(context, rawContactId, batchOperation);
}
}
else {
if(!contact.isDeleted()) {
Log.e("SYNCING CONTACTS", "Adding " + username);
addContact(context, account, contact, batchOperation);
ringtoneSync(resolver, username, context);
}
}
if(rawContactId != 0) {
if(!contact.isDeleted()) {
Log.e("SYNCING CONTACTS", "Updating " + username);
updateContact(context, resolver, account, contact, rawContactId, batchOperation);
ringtoneSync(resolver, username, context);
}
else {
Log.e("SYNCING CONTACTS", "Deleting " + username);
deleteContact(context, rawContactId, batchOperation);
}
}
else {
if(!contact.isDeleted()) {
Log.e("SYNCING CONTACTS", "Adding " + username);
addContact(context, account, contact, batchOperation);
/* -------> */ batchOperation.execute(); //EXECUTE BATCH OPERATION BEFORE SYNCING RINGTONE
ringtoneSync(resolver, username, context);
}
}
|
Open Contact information in Contact List using Phone Number of Contact Android Studio
Tag : java , By : Phil Austin
Date : March 29 2020, 07:55 AM
this will help The PhoneLookup api is meant just for this. String number = "0877777777";
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
String[] projection = new String[]{ PhoneLookup._ID, PhoneLookup.DISPLAY_NAME };
Cursor cur = getContentresolver().query(uri, projection, null, null, null);
if (cur != null) {
while (cur.moveToNext()) {
Long id = cur.getLong(0);
String name = cur.getString(1);
Log.d("My Contacts", "found: " + id + " - " + name);
}
cur.close();
}
String number = "0877777777";
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
String[] projection = new String[]{ PhoneLookup._ID };
Cursor cur = getContentresolver().query(uri, projection, null, null, null);
// if other contacts have that phone as well, we simply take the first contact found.
if (cur != null && cur.moveToNext()) {
Long id = cur.getLong(0);
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri contactUri = Uri.withAppendedPath(Contacts.CONTENT_URI, String.valueOf(id));
intent.setData(contactUri);
context.startActivity(intent);
cur.close();
}
|
Android contact lists - How to seperate my app created contacts from the rest of the phone?
Date : March 29 2020, 07:55 AM
it should still fix some issue Simple, don't use Android ContactsContract APIs, instead create and manage your own contacts in your own internal DB. You can create a class that extends SQLiteOpenHelper to help you get started with an SQLite internal Database. If you do need to use ContactsContract's APIs, you should put all your app's RawContacts with your app's ACCOUNT_NAME / ACCOUNT_TYPE pair so other apps can know that RawContact is related to your app, and you can then make your account hidden, so suggest to contacts app not to display those contacts. However, you can't force that suggestion, and other apps or users can make your contacts visible.
|
Sync newly inserted contact in android contact list with Whatsapp to get linked
Date : March 29 2020, 07:55 AM
|