Android APIs
public class

QuickContactBadge

extends ImageView
implements View.OnClickListener
java.lang.Object
   ↳ android.view.View
     ↳ android.widget.ImageView
       ↳ android.widget.QuickContactBadge

Class Overview

Widget used to show an image with the standard QuickContact badge and on-click behavior.

Summary

[Expand]
Inherited XML Attributes
From class android.widget.ImageView
From class android.view.View
[Expand]
Inherited Constants
From class android.view.View
Fields
protected String[] mExcludeMimes
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
QuickContactBadge(Context context)
QuickContactBadge(Context context, AttributeSet attrs)
QuickContactBadge(Context context, AttributeSet attrs, int defStyleAttr)
QuickContactBadge(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
Public Methods
void assignContactFromEmail(String emailAddress, boolean lazyLookup, Bundle extras)
Assign a contact based on an email address.
void assignContactFromEmail(String emailAddress, boolean lazyLookup)
Assign a contact based on an email address.
void assignContactFromPhone(String phoneNumber, boolean lazyLookup)
Assign a contact based on a phone number.
void assignContactFromPhone(String phoneNumber, boolean lazyLookup, Bundle extras)
Assign a contact based on a phone number.
void assignContactUri(Uri contactUri)
Assign the contact uri that this QuickContactBadge should be associated with.
void drawableHotspotChanged(float x, float y)
This function is called whenever the view hotspot changes and needs to be propagated to drawables or child views managed by the view.
CharSequence getAccessibilityClassName()
Return the class name of this object to be used for accessibility purposes.
void onClick(View v)
Called when a view has been clicked.
void setExcludeMimes(String[] excludeMimes)
Set a list of specific MIME-types to exclude and not display.
void setImageToDefault()
Resets the contact photo to the default state.
void setMode(int size)
This call has no effect anymore, as there is only one QuickContact mode
void setOverlay(Drawable overlay)
Assigns the drawable that is to be drawn on top of the assigned contact photo.
void setPrioritizedMimeType(String prioritizedMimeType)
Set which mimetype should be prioritized in the QuickContacts UI.
Protected Methods
void drawableStateChanged()
This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.
void onDraw(Canvas canvas)
Implement this to do your drawing.
[Expand]
Inherited Methods
From class android.widget.ImageView
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource
From interface android.view.View.OnClickListener

Fields

protected String[] mExcludeMimes

Added in API level 5

Public Constructors

public QuickContactBadge (Context context)

Added in API level 5

Parameters
context Context

public QuickContactBadge (Context context, AttributeSet attrs)

Added in API level 5

Parameters
context Context
attrs AttributeSet

public QuickContactBadge (Context context, AttributeSet attrs, int defStyleAttr)

Added in API level 5

Parameters
context Context
attrs AttributeSet
defStyleAttr int

public QuickContactBadge (Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Added in API level 21

Parameters
context Context
attrs AttributeSet
defStyleAttr int
defStyleRes int

Public Methods

public void assignContactFromEmail (String emailAddress, boolean lazyLookup, Bundle extras)

Added in API level 18

Assign a contact based on an email address. This should only be used when the contact's URI is not available, as an extra query will have to be performed to lookup the URI based on the email.

Parameters
emailAddress String: The email address of the contact.
lazyLookup boolean: If this is true, the lookup query will not be performed until this view is clicked.
extras Bundle: A bundle of extras to populate the contact edit page with if the contact is not found and the user chooses to add the email address to an existing contact or create a new contact. Uses the same string constants as those found in ContactsContract.Intents.Insert

public void assignContactFromEmail (String emailAddress, boolean lazyLookup)

Added in API level 5

Assign a contact based on an email address. This should only be used when the contact's URI is not available, as an extra query will have to be performed to lookup the URI based on the email.

Parameters
emailAddress String: The email address of the contact.
lazyLookup boolean: If this is true, the lookup query will not be performed until this view is clicked.

public void assignContactFromPhone (String phoneNumber, boolean lazyLookup)

Added in API level 5

Assign a contact based on a phone number. This should only be used when the contact's URI is not available, as an extra query will have to be performed to lookup the URI based on the phone number.

Parameters
phoneNumber String: The phone number of the contact.
lazyLookup boolean: If this is true, the lookup query will not be performed until this view is clicked.

public void assignContactFromPhone (String phoneNumber, boolean lazyLookup, Bundle extras)

Added in API level 18

Assign a contact based on a phone number. This should only be used when the contact's URI is not available, as an extra query will have to be performed to lookup the URI based on the phone number.

Parameters
phoneNumber String: The phone number of the contact.
lazyLookup boolean: If this is true, the lookup query will not be performed until this view is clicked.
extras Bundle: A bundle of extras to populate the contact edit page with if the contact is not found and the user chooses to add the phone number to an existing contact or create a new contact. Uses the same string constants as those found in ContactsContract.Intents.Insert

public void assignContactUri (Uri contactUri)

Added in API level 5

Assign the contact uri that this QuickContactBadge should be associated with. Note that this is only used for displaying the QuickContact window and won't bind the contact's photo for you. Call setImageDrawable(Drawable) to set the photo.

Parameters
contactUri Uri: Either a CONTENT_URI or CONTENT_LOOKUP_URI style URI.

public void drawableHotspotChanged (float x, float y)

Added in API level 21

This function is called whenever the view hotspot changes and needs to be propagated to drawables or child views managed by the view.

Dispatching to child views is handled by dispatchDrawableHotspotChanged(float, float).

Be sure to call through to the superclass when overriding this function.

Parameters
x float: hotspot x coordinate
y float: hotspot y coordinate

public CharSequence getAccessibilityClassName ()

Added in API level 23

Return the class name of this object to be used for accessibility purposes. Subclasses should only override this if they are implementing something that should be seen as a completely new class of view when used by accessibility, unrelated to the class it is deriving from. This is used to fill in AccessibilityNodeInfo.setClassName.

Returns
CharSequence

public void onClick (View v)

Added in API level 5

Called when a view has been clicked.

Parameters
v View: The view that was clicked.

public void setExcludeMimes (String[] excludeMimes)

Added in API level 5

Set a list of specific MIME-types to exclude and not display. For example, this can be used to hide the CONTENT_ITEM_TYPE profile icon.

Parameters
excludeMimes String

public void setImageToDefault ()

Added in API level 11

Resets the contact photo to the default state.

public void setMode (int size)

Added in API level 5

This call has no effect anymore, as there is only one QuickContact mode

Parameters
size int

public void setOverlay (Drawable overlay)

Added in API level 21

Assigns the drawable that is to be drawn on top of the assigned contact photo.

Parameters
overlay Drawable: Drawable to be drawn over the assigned contact photo. Must have a non-zero instrinsic width and height.

public void setPrioritizedMimeType (String prioritizedMimeType)

Added in API level 23

Set which mimetype should be prioritized in the QuickContacts UI. For example, passing the value CONTENT_ITEM_TYPE can cause emails to be displayed more prominently in QuickContacts.

Parameters
prioritizedMimeType String

Protected Methods

protected void drawableStateChanged ()

Added in API level 5

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

If the View has a StateListAnimator, it will also be called to run necessary state change animations.

Be sure to call through to the superclass when overriding this function.

protected void onDraw (Canvas canvas)

Added in API level 5

Implement this to do your drawing.

Parameters
canvas Canvas: the canvas on which the background will be drawn