在 Android 中创建不可见的联系人组
我想要的是隐藏联系人列表中的联系人。 因此,为了实现这一目标,我进行了很多尝试并进行了很多搜索。最后我知道我们可以生成一个不可见的组,并且可以将联系人分配给该组,以便联系人不可见。
我尝试过,但没有成功。即使我设置了 ContactsContact.Group
的 GROUP_VISIBLE
字段,我也无法使我的组不可见。
这就是我尝试创建不可见组的方法:
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
ops.add(ContentProviderOperation
.newInsert(ContactsContract.Groups.CONTENT_URI)
.withValue(ContactsContract.Groups.GROUP_VISIBLE, 0)
.withValue(ContactsContract.Groups.TITLE, "InViGroup").build());
try {
getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
} catch (Exception e) {
Log.e("Error", e.toString());
}
我可以将联系人添加到该组,但联系人在电话簿或联系人列表中可见。
我的主要目标是隐藏联系人列表中的联系人。有什么想法吗?如何使我选择的联系人不可见?
What I want is to hide contacts from the contact list.
So to achieve this I tried a lot and searched a lot. Finally I've come to know that we can generate an invisible group and we can assign contacts to that group so that contacts will be invisible.
I tried that, but had no success. Even when I set the GROUP_VISIBLE
field of ContactsContact.Group
s, I am not able to make my group invisible.
This is what I have tried to create a invisible group:
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
ops.add(ContentProviderOperation
.newInsert(ContactsContract.Groups.CONTENT_URI)
.withValue(ContactsContract.Groups.GROUP_VISIBLE, 0)
.withValue(ContactsContract.Groups.TITLE, "InViGroup").build());
try {
getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
} catch (Exception e) {
Log.e("Error", e.toString());
}
I am able to add contacts to this group but the contacts are visible in the phone book or the contact list.
My main goal is to hide the contact from contact list. Any ideas? How can I make my selected contacts invisible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
莫里西,我用这个玩了很多,让它看不见。即使我能够使用 GROUP_VISIBLE 创建一个组来设置 true 和 false 两者。但无论我设置的是真还是假,我添加的联系人仍然对联系人应用程序可见,所以最后我创建了自己的联系人数据库,在我自己的应用程序中维护。
这比仅仅创建不可见的组和联系人更困难,因为您必须维护与联系人应用程序的数据库相关的每个字段和表。因此,如果您找到使其不可见的方法,请告诉我。
不过,如果您想要安全性,就像没有人可以通过代码访问或使其可见一样,我认为您应该创建自己的数据库方法,我选择了它作为我的最后一个选项。
Maurycy, I played a lot with this to make it invisible. Even i am able to create a group with GROUP_VISIBLE to set true and false both. But whatever i set whether true or false the contacts i added are still visible to contacts app so finally i have created my own database of contacts maintaining in my own app.
It's more difficult than just to make invisible group and contacts in that as you have to maintain each and every fields and table related to contacts app's database. So if you have found ay way to make it invisible please let me know.
Still if you want security like no one can access or make it visible through code too than i think you should go with creating your own database method which i have selected as my last option.
我在这里发现了一个问题,询问这个问题的人有一个代码来添加联系人,这似乎使他们不可见:
联系人 API 将联系人存储为隐形接触:如何使其可见?
I found a question here on SO where the person asking it has a code to add contacts that seems to make them invisible:
Contact API storing contact as an invisible contact: How to make it visible?