Android: strange behaviour in QuickContactBadge

耗尽温柔 提交于 2019-12-01 09:06:14

问题


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:

  <?xml version="1.0" encoding="utf-8"?>   <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"></QuickContactBadge>       </LinearLayout>   

How can i see the badge?

Thanks in advance c.


回答1:


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

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



回答2:


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.



来源:https://stackoverflow.com/questions/5530625/android-strange-behaviour-in-quickcontactbadge

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!