Added in API level 1

AsyncQueryHandler


abstract class AsyncQueryHandler : Handler

A helper class to help make handling asynchronous ContentResolver queries easier.

Summary

Nested classes

open

Public constructors

Public methods
Unit

Attempts to cancel operation that has not already started.

open Unit

Unit
startDelete(token: Int, cookie: Any!, uri: Uri!, selection: String!, selectionArgs: Array<String!>!)

This method begins an asynchronous delete.

Unit
startInsert(token: Int, cookie: Any!, uri: Uri!, initialValues: ContentValues!)

This method begins an asynchronous insert.

open Unit
startQuery(token: Int, cookie: Any!, uri: Uri!, projection: Array<String!>!, selection: String!, selectionArgs: Array<String!>!, orderBy: String!)

This method begins an asynchronous query.

Unit
startUpdate(token: Int, cookie: Any!, uri: Uri!, values: ContentValues!, selection: String!, selectionArgs: Array<String!>!)

This method begins an asynchronous update.

Protected methods
open Handler!

open Unit
onDeleteComplete(token: Int, cookie: Any!, result: Int)

Called when an asynchronous delete is completed.

open Unit
onInsertComplete(token: Int, cookie: Any!, uri: Uri!)

Called when an asynchronous insert is completed.

open Unit
onQueryComplete(token: Int, cookie: Any!, cursor: Cursor!)

Called when an asynchronous query is completed.

open Unit
onUpdateComplete(token: Int, cookie: Any!, result: Int)

Called when an asynchronous update is completed.

Inherited functions
Handler createAsync(looper: Looper)

Create a new Handler whose posted messages and runnables are not subject to synchronization barriers such as display vsync.

Messages sent to an async handler are guaranteed to be ordered with respect to one another, but not necessarily with respect to messages from other Handlers.

Handler createAsync(looper: Looper, callback: Handler.Callback)

Create a new Handler whose posted messages and runnables are not subject to synchronization barriers such as display vsync.

Messages sent to an async handler are guaranteed to be ordered with respect to one another, but not necessarily with respect to messages from other Handlers.

Unit dispatchMessage(msg: Message)

Handle system messages here.

Unit dump(pw: Printer, prefix: String)

Looper getLooper()

String getMessageName(message: Message)

Returns a string representing the name of the specified message. The default implementation will either return the class name of the message callback if any, or the hexadecimal representation of the message "what" field.

Boolean hasCallbacks(r: Runnable)

Check if there are any pending posts of messages with callback r in the message queue.

Boolean hasMessages(what: Int)

Check if there are any pending posts of messages with code 'what' in the message queue.

Boolean hasMessages(what: Int, object: Any?)

Check if there are any pending posts of messages with code 'what' and whose obj is 'object' in the message queue.

Message obtainMessage()

Returns a new Message from the global message pool. More efficient than creating and allocating new instances. The retrieved message has its handler set to this instance (Message.target == this). If you don't want that facility, just call Message.obtain() instead.

Message obtainMessage(what: Int)

Same as obtainMessage(), except that it also sets the what member of the returned Message.

Message obtainMessage(what: Int, arg1: Int, arg2: Int)

Same as obtainMessage(), except that it also sets the what, arg1 and arg2 members of the returned Message.

Message obtainMessage(what: Int, arg1: Int, arg2: Int, obj: Any?)

Same as obtainMessage(), except that it also sets the what, obj, arg1,and arg2 values on the returned Message.

Message obtainMessage(what: Int, obj: Any?)

Same as obtainMessage(), except that it also sets the what and obj members of the returned Message.

Boolean post(r: Runnable)

Causes the Runnable r to be added to the message queue. The runnable will be run on the thread to which this handler is attached.

Boolean postAtFrontOfQueue(r: Runnable)

Posts a message to an object that implements Runnable. Causes the Runnable r to executed on the next iteration through the message queue. The runnable will be run on the thread to which this handler is attached. This method is only for use in very special circumstances -- it can easily starve the message queue, cause ordering problems, or have other unexpected side-effects.

Boolean postAtTime(r: Runnable, token: Any?, uptimeMillis: Long)

Causes the Runnable r to be added to the message queue, to be run at a specific time given by uptimeMillis. The time-base is android.os.SystemClock#uptimeMillis. Time spent in deep sleep will add an additional delay to execution. The runnable will be run on the thread to which this handler is attached.

Boolean postAtTime(r: Runnable, uptimeMillis: Long)

Causes the Runnable r to be added to the message queue, to be run at a specific time given by uptimeMillis. The time-base is android.os.SystemClock#uptimeMillis. Time spent in deep sleep will add an additional delay to execution. The runnable will be run on the thread to which this handler is attached.

Boolean postDelayed(r: Runnable, token: Any?, delayMillis: Long)

Causes the Runnable r to be added to the message queue, to be run after the specified amount of time elapses. The runnable will be run on the thread to which this handler is attached. The time-base is android.os.SystemClock#uptimeMillis. Time spent in deep sleep will add an additional delay to execution.

Boolean postDelayed(r: Runnable, delayMillis: Long)

Causes the Runnable r to be added to the message queue, to be run after the specified amount of time elapses. The runnable will be run on the thread to which this handler is attached. The time-base is android.os.SystemClock#uptimeMillis. Time spent in deep sleep will add an additional delay to execution.

Unit removeCallbacks(r: Runnable)

Remove any pending posts of Runnable r that are in the message queue.

Unit removeCallbacks(r: Runnable, token: Any?)

Remove any pending posts of Runnable r with Object token that are in the message queue. If token is null, all callbacks will be removed.

Unit removeCallbacksAndMessages(token: Any?)

Remove any pending posts of callbacks and sent messages whose obj is token. If token is null, all callbacks and messages will be removed.

Unit removeMessages(what: Int)

Remove any pending posts of messages with code 'what' that are in the message queue. Note that `Message#what` is 0 unless otherwise set. When calling `postMessage(Runnable)` or `postAtTime(Runnable, long)`, the `Runnable` is internally wrapped with a `Message` whose `what` is 0. Calling `removeMessages(0)` will remove all messages without a `what`, including posted `Runnable`s.

Unit removeMessages(what: Int, object: Any?)

Remove any pending posts of messages with code 'what' and whose obj is 'object' that are in the message queue. If object is null, all messages will be removed.

Boolean sendEmptyMessage(what: Int)

Sends a Message containing only the what value.

Boolean sendEmptyMessageAtTime(what: Int, uptimeMillis: Long)

Sends a Message containing only the what value, to be delivered at a specific time.

Boolean sendEmptyMessageDelayed(what: Int, delayMillis: Long)

Sends a Message containing only the what value, to be delivered after the specified amount of time elapses.

Boolean sendMessage(msg: Message)

Pushes a message onto the end of the message queue after all pending messages before the current time. It will be received in handleMessage, in the thread attached to this handler.

Boolean sendMessageAtFrontOfQueue(msg: Message)

Enqueue a message at the front of the message queue, to be processed on the next iteration of the message loop. You will receive it in handleMessage, in the thread attached to this handler. This method is only for use in very special circumstances -- it can easily starve the message queue, cause ordering problems, or have other unexpected side-effects.

Boolean sendMessageAtTime(msg: Message, uptimeMillis: Long)

Enqueue a message into the message queue after all pending messages before the absolute time (in milliseconds) uptimeMillis. The time-base is android.os.SystemClock#uptimeMillis. Time spent in deep sleep will add an additional delay to execution. You will receive it in handleMessage, in the thread attached to this handler.

Boolean sendMessageDelayed(msg: Message, delayMillis: Long)

Enqueue a message into the message queue after all pending messages before (current time + delayMillis). You will receive it in handleMessage, in the thread attached to this handler.

String toString()

Public constructors

AsyncQueryHandler

Added in API level 1
AsyncQueryHandler(cr: ContentResolver!)

Public methods

cancelOperation

Added in API level 1
fun cancelOperation(token: Int): Unit

Attempts to cancel operation that has not already started. Note that there is no guarantee that the operation will be canceled. They still may result in a call to on[Query/Insert/Update/Delete]Complete after this call has completed.

Parameters
token Int: The token representing the operation to be canceled. If multiple operations have the same token they will all be canceled.

handleMessage

Added in API level 1
open fun handleMessage(msg: Message): Unit
Parameters
msg Message: This value cannot be null.

startDelete

Added in API level 1
fun startDelete(
    token: Int,
    cookie: Any!,
    uri: Uri!,
    selection: String!,
    selectionArgs: Array<String!>!
): Unit

This method begins an asynchronous delete. When the delete operation is done onDeleteComplete is called.

Parameters
token Int: A token passed into onDeleteComplete to identify the delete operation.
cookie Any!: An object that gets passed into onDeleteComplete
uri Uri!: the Uri passed to the delete operation.
selection String!: the where clause.

startInsert

Added in API level 1
fun startInsert(
    token: Int,
    cookie: Any!,
    uri: Uri!,
    initialValues: ContentValues!
): Unit

This method begins an asynchronous insert. When the insert operation is done onInsertComplete is called.

Parameters
token Int: A token passed into onInsertComplete to identify the insert operation.
cookie Any!: An object that gets passed into onInsertComplete
uri Uri!: the Uri passed to the insert operation.
initialValues ContentValues!: the ContentValues parameter passed to the insert operation.

startQuery

Added in API level 1
open fun startQuery(
    token: Int,
    cookie: Any!,
    uri: Uri!,
    projection: Array<String!>!,
    selection: String!,
    selectionArgs: Array<String!>!,
    orderBy: String!
): Unit

This method begins an asynchronous query. When the query is done onQueryComplete is called.

Parameters
token Int: A token passed into onQueryComplete to identify the query.
cookie Any!: An object that gets passed into onQueryComplete
uri Uri!: The URI, using the content:// scheme, for the content to retrieve.
projection Array<String!>!: A list of which columns to return. Passing null will return all columns, which is discouraged to prevent reading data from storage that isn't going to be used.
selection String!: A filter declaring which rows to return, formatted as an SQL WHERE clause (excluding the WHERE itself). Passing null will return all rows for the given URI.
selectionArgs Array<String!>!: You may include ?s in selection, which will be replaced by the values from selectionArgs, in the order that they appear in the selection. The values will be bound as Strings.
orderBy String!: How to order the rows, formatted as an SQL ORDER BY clause (excluding the ORDER BY itself). Passing null will use the default sort order, which may be unordered.

startUpdate

Added in API level 1
fun startUpdate(
    token: Int,
    cookie: Any!,
    uri: Uri!,
    values: ContentValues!,
    selection: String!,
    selectionArgs: Array<String!>!
): Unit

This method begins an asynchronous update. When the update operation is done onUpdateComplete is called.

Parameters
token Int: A token passed into onUpdateComplete to identify the update operation.
cookie Any!: An object that gets passed into onUpdateComplete
uri Uri!: the Uri passed to the update operation.
values ContentValues!: the ContentValues parameter passed to the update operation.

Protected methods

createHandler

Added in API level 1
protected open fun createHandler(looper: Looper!): Handler!

onDeleteComplete

Added in API level 1
protected open fun onDeleteComplete(
    token: Int,
    cookie: Any!,
    result: Int
): Unit

Called when an asynchronous delete is completed.

Parameters
token Int: the token to identify the query, passed in from startDelete.
cookie Any!: the cookie object that's passed in from startDelete.
result Int: the result returned from the delete operation

onInsertComplete

Added in API level 1
protected open fun onInsertComplete(
    token: Int,
    cookie: Any!,
    uri: Uri!
): Unit

Called when an asynchronous insert is completed.

Parameters
token Int: the token to identify the query, passed in from startInsert.
cookie Any!: the cookie object that's passed in from startInsert.
uri Uri!: the uri returned from the insert operation.

onQueryComplete

Added in API level 1
protected open fun onQueryComplete(
    token: Int,
    cookie: Any!,
    cursor: Cursor!
): Unit

Called when an asynchronous query is completed.

Parameters
token Int: the token to identify the query, passed in from startQuery.
cookie Any!: the cookie object passed in from startQuery.
cursor Cursor!: The cursor holding the results from the query.

onUpdateComplete

Added in API level 1
protected open fun onUpdateComplete(
    token: Int,
    cookie: Any!,
    result: Int
): Unit

Called when an asynchronous update is completed.

Parameters
token Int: the token to identify the query, passed in from startUpdate.
cookie Any!: the cookie object that's passed in from startUpdate.
result Int: the result returned from the update operation