Example usage for android.os Message recycle

List of usage examples for android.os Message recycle

Introduction

In this page you can find the example usage for android.os Message recycle.

Prototype

public void recycle() 

Source Link

Document

Return a Message instance to the global pool.

Usage

From source file:Main.java

public static void recycleMessage(Message paramMessage) {
    if (paramMessage == null)
        return;/*from w  w w.j  ava2 s. c o  m*/
    paramMessage.recycle();
}

From source file:jmri.enginedriver.threaded_application.java

public boolean sendMsgDelay(Handler h, long delayMs, int msgType, String msgBody, int msgArg1, int msgArg2) {
    boolean sent = false;
    if (h != null) {
        Message msg = Message.obtain();
        msg.what = msgType;//from  ww  w  . ja v a 2  s .  c  o m
        msg.obj = new String(msgBody);
        msg.arg1 = msgArg1;
        msg.arg2 = msgArg2;
        try {
            sent = h.sendMessageDelayed(msg, delayMs);
        } catch (Exception e) {
        }
        if (!sent)
            msg.recycle();
    }
    return sent;
}