android-contacts

Android QuickContactBadge with letters like Android Lollipop

若如初见. 提交于 2019-12-03 20:16:21
问题 I have a list of contacts and I want to show in each contact's QuickContactBadge the first letter of his name. Can I create the images in runtime? This is like Android Lollipop, where contacts and dialer uses QuickContactBadge with letters: 回答1: I use a function to generate these images. public static Bitmap generateCircleBitmap(Context context, int circleColor, float diameterDP, String text){ final int textColor = 0xffffffff; DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics()

Fetch contact photo in android gives null

送分小仙女□ 提交于 2019-12-03 16:39:35
I want to fetch the photo of the contact while a user enters number.By using phone number i am getting users name but for image it shows null. my code is following : public class NewtempActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final ImageView img = (ImageView) findViewById(R.id.imageView1); final EditText edit = (EditText) findViewById(R.id.editText1); TextView txt = (TextView) findViewById(R.id.textView1); Button btn = (Button) findViewById(R.id.button1); btn.setOnClickListener

How to add contacts programmatically in Android?

早过忘川 提交于 2019-12-03 16:19:13
I have tried this but Contacts were not added! ContentResolver cr = this.getContentResolver(); ContentValues cv = new ContentValues(); cv.put(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, "sai1"); cv.put(ContactsContract.CommonDataKinds.Phone.NUMBER, "9640954335"); cv.put(ContactsContract.CommonDataKinds.Phone.TYPE, ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE); cr.insert(ContactsContract.RawContacts.CONTENT_URI, cv); bindal Try to use following code ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); int rawContactInsertIndex = ops.size(); Log.i(

Android: Get updated and deleted contact only

我只是一个虾纸丫 提交于 2019-12-03 14:46:39
问题 I am developing an application in which i am working on Android Contacts and not able to move ahead. In app the need of application is that the contact which is updated should send to server or the contact which is deleted should send to server for sync. I am using the contact service as: public class ContactService extends Service { private int mContactCount; Cursor cursor = null; static ContentResolver mContentResolver = null; // Content provider authority public static final String

Using CursorLoader to get emails causes duplication of emails

我只是一个虾纸丫 提交于 2019-12-03 11:58:54
I am trying to get email ids of uses contacts. For that I am using Cursor Loader. There is one problem I am getting duplicate email ids also. How to remove email duplicacy. Should I use raw query "SELECT DISTINCT" instead of using CursorLoader or there is some other solution? @Override public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) { String[] projection = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.CommonDataKinds.Email.DATA}; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; String

Android get sms from inbox, optimized way to read all messages and group them

不想你离开。 提交于 2019-12-03 11:04:12
Hi am implementing a SMS App, now am able to retrieve all messages with their respective contact info like display name, photo uri.. and am displaying them in a custom list where on item click takes you to respective discussion. Here my issues is the time taking to sync all these messages, I need to optimize this time. Each time i send a new message in the discussion view and go back to recent chats i need to only update the particular item, not the whole list. Here's my code: ReadSMS.java: public class ReadSMS { ArrayList<HashMap<Contact, ArrayList<OneComment>>> recentChats; Application

Want to create a new group in contacts programmatically

一曲冷凌霜 提交于 2019-12-03 10:08:22
问题 I want to create a new contact group. I can query the group and display all the group names but I can't create a group in android I tried as creating contacts method but not created... ContentResolver cr = this.getContentResolver(); groupValues = new ContentValues(); Log.e("Group","start"); groupValues.put(android.provider.Contacts.GroupMembership.GROUP_ID, 4); groupValues.put(android.provider.Contacts.GroupMembership.NAME, "Sriseshaa"); groupValues.put(android.provider.Contacts

Android - Get UserData using AccountManager / First and Last name of the phone owner

有些话、适合烂在心里 提交于 2019-12-03 08:58:52
问题 I want to prepopulate some of the fields in my application to help out user when he is subscribing for the service inside my app. So how would I get first name and last name of device's owner. I want to use default info tied to Google account; so far I got this: AccountManager am = AccountManager.get(this); Account[] accounts = am.getAccounts(); for (Account account : accounts) { if (account.type.compareTo("com.google") == 0) { String possibleEmail = account.name; // how to get firstname and

How to get all contacts from phonebook & SIM card in Android?

ε祈祈猫儿з 提交于 2019-12-03 08:51:30
问题 I am working to get all the contacts from phone book and SIM card in my application. I want to store those all contacts in my application SQLite DB. The code with which I am working is working fine in normal conditions. Getting problem in below conditions: with a contact without name, that is only number. Contacts from SIM card. These 2 types of contacts, are not provided to me by my code. I am using the below code: public void getDefaultContactsToDB(){ CallBackDatabase callbackDB = new

How to show custom type contact inside Contact like WhatsApp android

大城市里の小女人 提交于 2019-12-03 07:58:01
/** * Account type id */ public static final String ACCOUNT_TYPE = "com.test.app"; /** * Account name */ public static final String ACCOUNT_NAME = "Test"; public static void addContact(Context context, User contact) { ContentResolver resolver = context.getContentResolver(); resolver.delete(RawContacts.CONTENT_URI, RawContacts.ACCOUNT_TYPE + " = ?", new String[] { AccountConstants.ACCOUNT_TYPE }); ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); ops.add(ContentProviderOperation .newInsert( addCallerIsSyncAdapterParameter( RawContacts.CONTENT_URI, true))