add Message to Handler - Android Android OS

Android examples for Android OS:Message

Description

add Message to Handler

Demo Code


//package com.java2s;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

public class Main {
    public static void addMessage(Handler mHandler, String msgStr) {
        Message msg = Message.obtain();/*  w ww .j  a v  a 2  s  .c  om*/
        Bundle bundle = msg.getData();
        bundle.clear();
        bundle.putString("MSG", msgStr);
        mHandler.sendMessage(msg);
    }
}

Related Tutorials