Example usage for android.os Handler handleMessage

List of usage examples for android.os Handler handleMessage

Introduction

In this page you can find the example usage for android.os Handler handleMessage.

Prototype

public void handleMessage(Message msg) 

Source Link

Document

Subclasses must implement this to receive messages.

Usage

From source file:org.planetmono.dcuploader.SignOnRealName.java

public Runnable getMethodSignOff(final Application app, final Handler resultHandler) {
    return new Runnable() {
        public void run() {
            // AFAIK there is no way to sign off. Let the session die alone...
            Message m = resultHandler.obtainMessage();
            m.getData().putBoolean("result", true);
            resultHandler.handleMessage(m);
        }/*from w w  w  .ja v  a  2s.  c  o  m*/
    };
}

From source file:com.hoccer.api.android.AsyncLinccer.java

public void asyncShare(final String mode, final JSONObject payload, final Handler handler) {
    new Thread(new Runnable() {
        public void run() {

            Message msg = handler.obtainMessage();
            try {
                handler.handleMessage(handler.obtainMessage(MessageType.SEARCHING));
                msg.obj = share(mode, payload);

                if (msg.obj != null) {
                    msg.what = MessageType.SHARED;
                } else {
                    msg.what = MessageType.NOTHING_SHARED;
                }//w w  w.  ja  va2  s.c o m
            } catch (BadModeException e) {
                msg.what = MessageType.BAD_MODE;
                msg.obj = e;
            } catch (ClientActionException e) {
                msg.what = MessageType.BAD_CLIENT_ACTION;
                msg.obj = e;
            } catch (CollidingActionsException e) {
                msg.what = MessageType.COLLISION;
                msg.obj = e;
            } catch (Exception e) {
                msg.what = MessageType.UNKNOWN_EXCEPTION;
                msg.obj = e;
            }

            Log.v("Linccer", msg.what + " " + msg.obj);

            handler.handleMessage(msg);
        }
    }).start();
}

From source file:com.hoccer.api.android.AsyncLinccer.java

public void asyncReceive(final String mode, final Handler handler) {
    new Thread(new Runnable() {
        public void run() {

            Message msg = handler.obtainMessage();
            try {
                handler.handleMessage(handler.obtainMessage(MessageType.SEARCHING));
                msg.obj = receive(mode);

                if (msg.obj != null) {
                    msg.what = MessageType.RECEIVED;
                } else {
                    msg.what = MessageType.NOTHING_RECEIVED;
                }//  www .ja va  2 s. c  o  m
            } catch (BadModeException e) {
                msg.what = MessageType.BAD_MODE;
                msg.obj = e;
            } catch (ClientActionException e) {
                msg.what = MessageType.BAD_CLIENT_ACTION;
                msg.obj = e;
            } catch (CollidingActionsException e) {
                msg.what = MessageType.COLLISION;
                msg.obj = e;
            } catch (Exception e) {
                msg.what = MessageType.UNKNOWN_EXCEPTION;
                msg.obj = e;
            }

            Log.v("Linccer", msg.what + " " + msg.obj);

            handler.handleMessage(msg);
        }
    }).start();

}

From source file:org.planetmono.dcuploader.SignOnGallog.java

public Runnable getMethodSignOff(final Application app, final Handler resultHandler) {
    return new Runnable() {
        public void run() {
            HttpGet get = new HttpGet(SIGNOFF_URL + "?s_url=about:blank");
            try {
                app.sendGetRequest(get);
            } catch (Exception e) {
                e.printStackTrace();//w  w  w. j av a  2  s  . c  o m
            }

            Message m = resultHandler.obtainMessage();
            m.getData().putBoolean("result", true);
            resultHandler.handleMessage(m);
        }
    };
}