Example usage for android.os Message Message

List of usage examples for android.os Message Message

Introduction

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

Prototype

public Message() 

Source Link

Document

Constructor (but the preferred way to get a Message is to call #obtain() Message.obtain() ).

Usage

From source file:Main.java

public static void sendMessageHandler(Handler handler, int what, Object obj) {
    Message message = new Message();
    message.what = what;/*from  w w  w  .  ja  va  2  s  .  c  o  m*/
    message.obj = obj;
    handler.sendMessage(message);
}

From source file:Main.java

public static void PrintLog(String text) {
    if (mHandler != null) {
        Message meg = new Message();
        Bundle bundel = new Bundle();
        bundel.putString("MESSAGE", text);
        meg.setData(bundel);//from w w w .ja v a 2s  .  c o  m
        mHandler.sendMessage(meg);
    }
}

From source file:Main.java

public static void sendMessageHandler(Handler handler, int what, String key, String value) {
    Message message = new Message();
    message.what = what;//from w  w  w  . j  a  v  a 2s.c o  m
    Bundle bundle = new Bundle();
    bundle.putString(key, value);
    message.setData(bundle);
    handler.sendMessage(message);
}

From source file:Main.java

public static void sendMessageHandler(Handler handler, int what, String key, int value) {
    Message message = new Message();
    message.what = what;// w ww. j a v  a  2s.  c  o m
    Bundle bundle = new Bundle();
    bundle.putInt(key, value);
    message.setData(bundle);
    handler.sendMessage(message);
}

From source file:Main.java

public static void getNewsJSON(final String url, final Handler handler) {

    new Thread(new Runnable() {
        @Override//from   w  w w  .  j a  v a2 s. c  o  m
        public void run() {
            HttpURLConnection conn;
            InputStream is;
            try {
                conn = (HttpURLConnection) new URL(url).openConnection();
                conn.setRequestMethod("GET");
                is = conn.getInputStream();
                BufferedReader reader = new BufferedReader(new InputStreamReader(is));
                String line = "";
                StringBuffer result = new StringBuffer();
                while ((line = reader.readLine()) != null) {
                    result.append(line);
                }
                Message msg = new Message();
                msg.obj = result.toString();
                handler.sendMessage(msg);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }).start();
}

From source file:com.spoiledmilk.ibikecph.login.HTTPAccountHandler.java

public static Message performLogin(final UserData userData) {
    Message message = new Message();
    JsonNode result = null;/*  w  ww.  j  a va  2 s .c om*/
    JSONObject jsonPOST = new JSONObject();
    JSONObject jsonUser = new JSONObject();
    try {
        jsonUser.put("password", userData.getPassword());
        jsonUser.put("email", userData.getEmail());
        jsonPOST.put("user", jsonUser);
        result = HttpUtils.postToServer(Config.API_SERVER_LOGIN, jsonPOST);
        message = HttpUtils.JSONtoMessage(result);
    } catch (JSONException e) {
        LOG.e(e.getLocalizedMessage());
    }
    return message;
}

From source file:Main.java

public static void sendMessageHandler(Handler handler, int what, Bundle bundle) {
    Message message = new Message();
    message.what = what;//from   w w w . j ava  2 s.c om
    message.setData(bundle);
    handler.sendMessage(message);
}

From source file:Main.java

private static void nativeDelete() {
    Message msg = new Message();
    msg.what = ADMOB_HELPER_DELETE;
    mHandler.sendMessage(msg);
}

From source file:Main.java

private static void nativeLoadAd() {
    Message msg = new Message();
    msg.what = ADMOB_HELPER_LOAD_AD;
    mHandler.sendMessage(msg);
}

From source file:com.spoiledmilk.ibikecph.login.HTTPAccountHandler.java

public static Message performFacebookLogin(String fbToken) {

    Message message = new Message();
    try {/* w  ww  .  j  a  v a 2  s. co  m*/

        JsonNode result = null;
        JSONObject jsonPOST = new JSONObject();
        JSONObject jsonUser = new JSONObject();

        jsonUser.put("fb_token", fbToken);
        jsonPOST.put("user", jsonUser);
        result = HttpUtils.postToServer(Config.API_SERVER_LOGIN, jsonPOST);
        message = HttpUtils.JSONtoMessage(result);
    } catch (JSONException e) {
        LOG.e(e.getLocalizedMessage());
    }
    return message;
}