FileDocCategorySizeDatePackage
AsyncService.javaAPI DocAndroid 5.1 API3637Thu Mar 12 22:22:10 GMT 2015com.android.internal.util

AsyncService

public abstract class AsyncService extends android.app.Service
A service that receives Intents and IBinder transactions as messages via an AsyncChannel.

The Start Intent arrives as CMD_ASYNC_SERVICE_ON_START_INTENT with msg.arg1 = flags, msg.arg2 = startId, and msg.obj = intent.

Fields Summary
private static final String
TAG
protected static final boolean
DBG
public static final int
CMD_ASYNC_SERVICE_ON_START_INTENT
The command sent when a onStartCommand is invoked
public static final int
CMD_ASYNC_SERVICE_DESTROY
The command sent when a onDestroy is invoked
protected android.os.Messenger
mMessenger
Messenger transport
android.os.Handler
mHandler
Message Handler that will receive messages
AsyncServiceInfo
mAsyncServiceInfo
Constructors Summary
Methods Summary
public abstract com.android.internal.util.AsyncService$AsyncServiceInfocreateHandler()
Create the service's handler returning AsyncServiceInfo.

return
AsyncServiceInfo

public android.os.HandlergetHandler()
Get the handler


                 
       

            
       
        return mHandler;
    
public android.os.IBinderonBind(android.content.Intent intent)
Returns the Messenger's binder.

        return mMessenger.getBinder();
    
public voidonCreate()
onCreate

        super.onCreate();
        mAsyncServiceInfo = createHandler();
        mHandler = mAsyncServiceInfo.mHandler;
        mMessenger = new Messenger(mHandler);
    
public voidonDestroy()
Called when service is destroyed. After returning the service is dead and no more processing should be expected to occur.

        if (DBG) Slog.d(TAG, "onDestroy");

        Message msg = mHandler.obtainMessage();
        msg.what = CMD_ASYNC_SERVICE_DESTROY;
        mHandler.sendMessage(msg);
    
public intonStartCommand(android.content.Intent intent, int flags, int startId)
Sends the CMD_ASYNC_SERVICE_ON_START_INTENT message.

        if (DBG) Slog.d(TAG, "onStartCommand");

        Message msg = mHandler.obtainMessage();
        msg.what = CMD_ASYNC_SERVICE_ON_START_INTENT;
        msg.arg1 = flags;
        msg.arg2 = startId;
        msg.obj = intent;
        mHandler.sendMessage(msg);

        return mAsyncServiceInfo.mRestartFlags;