public class

Conversation

extends Object
java.lang.Object
   ↳ com.android.mms.data.Conversation

Class Overview

An interface for finding information about conversations and/or creating new ones.

Summary

Public Methods
static void asyncDeleteObsoleteThreads(AsyncQueryHandler handler, int token)
Remove any obsolete conversations sitting around on disk.
void blockMarkAsRead(boolean block)
synchronized void clearThreadId()
static Conversation createNew(Context context)
Create a new conversation with no recipients.
synchronized long ensureThreadId()
Guarantees that the conversation has been created in the database.
synchronized boolean equals(Object obj)
static Conversation from(Context context, Cursor cursor)
Returns a temporary Conversation (not representing one on disk) wrapping the contents of the provided cursor.
static Conversation get(Context context, ContactList recipients, boolean allowQuery)
Find the conversation matching the provided recipient set.
static Conversation get(Context context, long threadId, boolean allowQuery)
Find the conversation matching the provided thread ID.
static Conversation get(Context context, Uri uri, boolean allowQuery)
Find the conversation matching in the specified Uri.
synchronized long getDate()
Returns the time of the last update to this conversation in milliseconds, on the currentTimeMillis() timebase.
synchronized int getMessageCount()
Returns the number of messages in this conversation, excluding the draft (if it exists).
synchronized ContactList getRecipients()
Returns the recipient set of this conversation.
synchronized String getSnippet()
Returns a snippet of text from the most recent message in the conversation.
synchronized long getThreadId()
Returns the thread ID of this conversation.
static Uri getUri(long threadId)
This method is deprecated. No replacement.
synchronized Uri getUri()
Returns a content:// URI referring to this conversation, or null if it does not exist on disk yet.
synchronized boolean hasAttachment()
Returns true if any messages in the conversation have attachments.
synchronized boolean hasDraft()
Returns true if a draft message exists in this conversation.
synchronized boolean hasError()
Returns true if any messages in the conversation are in an error state.
boolean hasUnreadMessages()
Returns true if there are any unread messages in the conversation.
synchronized int hashCode()
static void init(Context context)
Set up the conversation cache.
static boolean loadingThreads()
Are we in the process of loading and caching all the threads?.
static void markAllConversationsAsSeen(Context context)
void markAsRead()
Marks all messages in this conversation as read and updates relevant notifications.
boolean sameRecipient(Uri uri)
Returns true if the recipient in the uri matches the recipient list in this conversation.
synchronized void setDraftState(boolean hasDraft)
Sets whether or not this conversation has a draft message.
synchronized void setRecipients(ContactList list)
Sets the list of recipients associated with this conversation.
static void startDelete(AsyncQueryHandler handler, int token, boolean deleteAll, long threadId)
Start a delete of the conversation with the specified thread ID.
static void startDeleteAll(AsyncQueryHandler handler, int token, boolean deleteAll)
Start deleting all conversations in the database.
static void startQueryForAll(AsyncQueryHandler handler, int token)
Start a query for all conversations in the database on the specified AsyncQueryHandler.
static void startQueryHaveLockedMessages(AsyncQueryHandler handler, long threadId, int token)
Check for locked messages in all threads or a specified thread.
synchronized String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static void asyncDeleteObsoleteThreads (AsyncQueryHandler handler, int token)

Remove any obsolete conversations sitting around on disk. Obsolete threads are threads that aren't referenced by any message in the pdu or sms tables.

public void blockMarkAsRead (boolean block)

public synchronized void clearThreadId ()

public static Conversation createNew (Context context)

Create a new conversation with no recipients. setRecipients(ContactList) can be called as many times as you like; the conversation will not be created in the database until ensureThreadId() is called.

public synchronized long ensureThreadId ()

Guarantees that the conversation has been created in the database. This will make a blocking database call if it hasn't.

Returns
  • The thread ID of this conversation in the database

public synchronized boolean equals (Object obj)

public static Conversation from (Context context, Cursor cursor)

Returns a temporary Conversation (not representing one on disk) wrapping the contents of the provided cursor. The cursor should be the one returned to your AsyncQueryHandler passed in to startQueryForAll(AsyncQueryHandler, int). The recipient list of this conversation can be empty if the results were not in cache.

public static Conversation get (Context context, ContactList recipients, boolean allowQuery)

Find the conversation matching the provided recipient set. When called with an empty recipient list, equivalent to createNew(Context).

public static Conversation get (Context context, long threadId, boolean allowQuery)

Find the conversation matching the provided thread ID.

public static Conversation get (Context context, Uri uri, boolean allowQuery)

Find the conversation matching in the specified Uri. Example forms: {@value content://mms-sms/conversations/3} or {@value sms:+12124797990}. When called with a null Uri, equivalent to createNew(Context).

public synchronized long getDate ()

Returns the time of the last update to this conversation in milliseconds, on the currentTimeMillis() timebase.

public synchronized int getMessageCount ()

Returns the number of messages in this conversation, excluding the draft (if it exists).

public synchronized ContactList getRecipients ()

Returns the recipient set of this conversation.

public synchronized String getSnippet ()

Returns a snippet of text from the most recent message in the conversation.

public synchronized long getThreadId ()

Returns the thread ID of this conversation. Can be zero if ensureThreadId() has not been called yet.

public static Uri getUri (long threadId)

This method is deprecated.
No replacement.

Return the Uri for all messages in the given thread ID.

public synchronized Uri getUri ()

Returns a content:// URI referring to this conversation, or null if it does not exist on disk yet.

public synchronized boolean hasAttachment ()

Returns true if any messages in the conversation have attachments.

public synchronized boolean hasDraft ()

Returns true if a draft message exists in this conversation.

public synchronized boolean hasError ()

Returns true if any messages in the conversation are in an error state.

public boolean hasUnreadMessages ()

Returns true if there are any unread messages in the conversation.

public synchronized int hashCode ()

public static void init (Context context)

Set up the conversation cache. To be called once at application startup time.

public static boolean loadingThreads ()

Are we in the process of loading and caching all the threads?.

public static void markAllConversationsAsSeen (Context context)

public void markAsRead ()

Marks all messages in this conversation as read and updates relevant notifications. This method returns immediately; work is dispatched to a background thread.

public boolean sameRecipient (Uri uri)

Returns true if the recipient in the uri matches the recipient list in this conversation.

public synchronized void setDraftState (boolean hasDraft)

Sets whether or not this conversation has a draft message.

public synchronized void setRecipients (ContactList list)

Sets the list of recipients associated with this conversation. If called, ensureThreadId() must be called before the next operation that depends on this conversation existing in the database (e.g. storing a draft message to it).

public static void startDelete (AsyncQueryHandler handler, int token, boolean deleteAll, long threadId)

Start a delete of the conversation with the specified thread ID.

Parameters
handler An AsyncQueryHandler that will receive onDeleteComplete upon completion of the conversation being deleted
token The token that will be passed to onDeleteComplete
deleteAll Delete the whole thread including locked messages
threadId Thread ID of the conversation to be deleted

public static void startDeleteAll (AsyncQueryHandler handler, int token, boolean deleteAll)

Start deleting all conversations in the database.

Parameters
handler An AsyncQueryHandler that will receive onDeleteComplete upon completion of all conversations being deleted
token The token that will be passed to onDeleteComplete
deleteAll Delete the whole thread including locked messages

public static void startQueryForAll (AsyncQueryHandler handler, int token)

Start a query for all conversations in the database on the specified AsyncQueryHandler.

Parameters
handler An AsyncQueryHandler that will receive onQueryComplete upon completion of the query
token The token that will be passed to onQueryComplete

public static void startQueryHaveLockedMessages (AsyncQueryHandler handler, long threadId, int token)

Check for locked messages in all threads or a specified thread.

Parameters
handler An AsyncQueryHandler that will receive onQueryComplete upon completion of looking for locked messages
threadId The threadId of the thread to search. -1 means all threads
token The token that will be passed to onQueryComplete

public synchronized String toString ()