简体   繁体   中英

Android: strange behaviour in QuickContactBadge

I'm trying to use the 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:

<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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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