简体   繁体   English

Android:QuickContactBadge 中的奇怪行为

[英]Android: strange behaviour in QuickContactBadge

I'm trying to use the QuickContactBadge .我正在尝试使用QuickContactBadge I would like to get an effect like this:我想得到这样的效果:

But when I write this code:但是当我写这段代码时:

QuickContactBadge badge = (QuickContactBadge) findViewById(R.id.badge_small);  
badge.assignContactFromPhone("831-555-1212", true);  

I don't see the badge but I am redirected to the Contact page.我没有看到徽章,但我被重定向到联系页面。

Here is layout.xml:这是layout.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <QuickContactBadge
        android:id="@+id/badge_small"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/icon" />
</LinearLayout>  

How can I see the badge?我怎么能看到徽章?

您需要将 READ_CONTACTS 权限添加到您的 AndroidManifest.xml 文件中:

<uses-permission android:name="android.permission.READ_CONTACTS" />

1) A caution: you must use API Level 5 or above to use this function. 1) 注意事项:必须使用 API Level 5 或以上才能使用此功能。

2) For taking to you on contact page: The function of this badge works in such a way that if a contact is already there then it will show you the quick contact badge else it will take you the "add contact" screen with this phone no pre filled in contact's info. 2)用于在联系人页面上带给您:此徽章的功能是这样工作的,如果联系人已经存在,则它会向您显示快速联系徽章,否则它将带您使用此手机的“添加联系人”屏幕没有预先填写联系人的信息。

So now, you need to save a contact with the phone no defined.所以现在,您需要保存未定义电话的联系人。 After saving the contact, when you will click on the button next time, it will show you the desired results.保存联系人后,当您下次单击该按钮时,它将显示您想要的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM