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 onClick(View v)
Called when a view has been clicked.
void onInitializeAccessibilityEvent(AccessibilityEvent event)
Initializes an AccessibilityEvent with information about this View which is the event source.
void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)
Initializes an AccessibilityNodeInfo with information about this view.
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.
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.View.OnClickListener
From interface android.view.accessibility.AccessibilityEventSource

Fields

protected String[] mExcludeMimes

Added in API level 5

Public Constructors

public QuickContactBadge (Context context)

Added in API level 5

public QuickContactBadge (Context context, AttributeSet attrs)

Added in API level 5

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

Added in API level 5

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

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 The email address of the contact.
lazyLookup If this is true, the lookup query will not be performed until this view is clicked.
extras 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 The email address of the contact.
lazyLookup 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 The phone number of the contact.
lazyLookup 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 The phone number of the contact.
lazyLookup If this is true, the lookup query will not be performed until this view is clicked.
extras 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 Either a CONTENT_URI or CONTENT_LOOKUP_URI style URI.

public void onClick (View v)

Added in API level 5

Called when a view has been clicked.

Parameters
v The view that was clicked.

public void onInitializeAccessibilityEvent (AccessibilityEvent event)

Added in API level 14

Initializes an AccessibilityEvent with information about this View which is the event source. In other words, the source of an accessibility event is the view whose state change triggered firing the event.

Example: Setting the password property of an event in addition to properties set by the super implementation:

 public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
     super.onInitializeAccessibilityEvent(event);
     event.setPassword(true);
 }

If an View.AccessibilityDelegate has been specified via calling setAccessibilityDelegate(AccessibilityDelegate) its onInitializeAccessibilityEvent(View, AccessibilityEvent) is responsible for handling this call.

Note: Always call the super implementation before adding information to the event, in case the default implementation has basic information to add.

Parameters
event The event to initialize.

public void onInitializeAccessibilityNodeInfo (AccessibilityNodeInfo info)

Added in API level 14

Initializes an AccessibilityNodeInfo with information about this view. The base implementation sets:

Subclasses should override this method, call the super implementation, and set additional attributes.

If an View.AccessibilityDelegate has been specified via calling setAccessibilityDelegate(AccessibilityDelegate) its onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfo) is responsible for handling this call.

Parameters
info The instance to initialize.

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.

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

public void setOverlay (Drawable overlay)

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

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

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 the canvas on which the background will be drawn