开发者

Android: strange behaviour in QuickContactBadge

I'm trying to use the QuickContactBadge. I would like to get an effect like this:

Android: strange behaviour in QuickContactBadge

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>  开发者_StackOverflow

How can I see the badge?


You need to add the READ_CONTACTS permission to your AndroidManifest.xml file:

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜