我想我的应用程序与联系人管理器集成:整合我的应用程序联系
更确切地说:
当我在我的手机上运行联系的应用程序,然后我点击任何头像,弹出(快速联系人徽章)窗口出现与一些应用程序来选择(联系人,邮件等)我想添加我的应用程序在那个地方。
这可能吗?
我希望能够清楚。
在此先感谢。
我想我的应用程序与联系人管理器集成:整合我的应用程序联系
更确切地说:
当我在我的手机上运行联系的应用程序,然后我点击任何头像,弹出(快速联系人徽章)窗口出现与一些应用程序来选择(联系人,邮件等)我想添加我的应用程序在那个地方。
这可能吗?
我希望能够清楚。
在此先感谢。
嘿家伙终于我解决了这个添加一个自定义字段到ContactProvider,然后QuickContactBadge将链接它给你。
我的代码,用于添加,删除特定条目,删除我添加的所有条目。
private static final IM_LABEL = "Test protocol";
private static final LOG_TAG = "Log"
/**
* This method add my account under IM field at default Contact
* application
*
* Labeled with my custom protocol.
*
* @param contentResolver
* content resolver
* @param uid
* User id from android
* @param account
* account name
*/
public static void updateIMContactField(ContentResolver contentResolver,
String uid, String account) {
ContentValues contentValues = new ContentValues();
contentValues.put(ContactsContract.Data.RAW_CONTACT_ID,
Integer.parseInt(uid));
contentValues.put(ContactsContract.Data.MIMETYPE,
ContactsContract.CommonDataKinds.Im.CONTENT_ITEM_TYPE);
contentValues.put(ContactsContract.CommonDataKinds.Im.TYPE,
ContactsContract.CommonDataKinds.Im.TYPE_CUSTOM);
contentValues.put(ContactsContract.CommonDataKinds.Im.LABEL, IM_LABEL);
contentValues.put(ContactsContract.CommonDataKinds.Im.PROTOCOL,
ContactsContract.CommonDataKinds.Im.PROTOCOL_CUSTOM);
contentValues.put(ContactsContract.CommonDataKinds.Im.CUSTOM_PROTOCOL,
IM_LABEL);
contentValues.put(ContactsContract.CommonDataKinds.Im.DATA, account);
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
ops.add(ContentProviderOperation
.newInsert(ContactsContract.Data.CONTENT_URI)
.withValues(contentValues).build());
try {
contentResolver.applyBatch(ContactsContract.AUTHORITY, ops);
} catch (Exception e) {
Log.d(LOG_TAG, "Can't update Contact's IM field.");
}
}
/**
* This method remove IM entry at default Contact application.
*
* @param contentResolver
* content resolver
* @param uid
* User id from android
* @param account
* account name
*/
public static void removeIMContactField(ContentResolver contentResolver,
String uid, String account) {
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
ops.add(ContentProviderOperation
.newDelete(Data.CONTENT_URI)
.withSelection(
ContactsContract.Data.RAW_CONTACT_ID + "=? and "
+ ContactsContract.Data.MIMETYPE + "=? and "
+ ContactsContract.CommonDataKinds.Im.DATA
+ " = ?",
new String[] {
String.valueOf(uid),
ContactsContract.CommonDataKinds.Im.CONTENT_ITEM_TYPE,
account }).build());
try {
contentResolver.applyBatch(ContactsContract.AUTHORITY, ops);
} catch (Exception e) {
Log.d(LOG_TAG, "Can't delete Contact's IM field.");
}
}
/**
* This method remove IM all entries at default Contact application
*
* @param contentResolver
* content resolver
*/
public static void deleteAllIMContactField(ContentResolver contentResolver) {
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
ops.add(ContentProviderOperation
.newDelete(Data.CONTENT_URI)
.withSelection(
ContactsContract.Data.MIMETYPE
+ "= ? and "
+ ContactsContract.CommonDataKinds.Im.CUSTOM_PROTOCOL
+ "= ?",
new String[] {
ContactsContract.CommonDataKinds.Im.CONTENT_ITEM_TYPE,
IM_LABEL }).build());
try {
contentResolver.applyBatch(ContactsContract.AUTHORITY, ops);
} catch (Exception e) {
Log.d(LOG_TAG,
"An exception occurred when deleting all IM field of Contact.");
}
}
希望有人找到这个有用的。
你能否澄清一下:“嗨,我终于解决了这个问题,在ContactProvider中添加一个自定义字段,然后QuickContactBadge会为你链接。” – Chrispix 2011-11-09 17:53:32
如果您将自定义字段添加到ContactProvider,则您的应用将被列入QuickContactBadge。检查手机上的默认联系人应用程序,然后“点击”一个联系人,弹出窗口将显示(徽章)与一些可用的应用程序。我的意图是将我的应用添加到该徽章中,并且我发现您可以添加自己的字段并在该字段中放置一些信息,然后android会将您的应用与该特定联系人关联,因为我的应用拥有该自定义字段。 – vsm 2011-11-11 05:57:16
你能告诉我什么是帐户名?它只是简单的联系人姓名吗?当我尝试这个时,它给我例外applyBatch方法。请帮帮我。 – Rahil2952 2013-10-11 06:49:12
你是如何解决它的?我也想这样做。 – chrisonline 2011-05-19 13:10:39
到目前为止没有运气,是我的TODO列表中的一个未决任务,就像找到一些解决方案,我会在这里发布它。请做同样的:)。 – vsm 2011-05-19 16:32:07