List of usage examples for android.os Message setData
public void setData(Bundle data)
From source file:Main.java
public static void sendMessageHandler(Handler handler, int what, Bundle bundle) { Message message = new Message(); message.what = what;//from www . java 2 s. c o m message.setData(bundle); 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); mHandler.sendMessage(meg);/* w w w . java 2s . co m*/ } }
From source file:Main.java
static Message obtain(Handler handler, Runnable runnable, Object obj, int what) { Message msg = Message.obtain(handler, runnable); msg.obj = obj;/* w w w .java 2 s . co m*/ msg.arg1 = -1; msg.arg2 = -1; msg.replyTo = null; msg.setData(null); msg.what = what; return msg; }
From source file:Main.java
public static void sendMsg2Client(Messenger messenger, String sKey, String sObjParam, int iMsg) { if (messenger == null) { return;// ww w. ja v a2 s . c om } try { Bundle b = new Bundle(); if (null != sKey) { b.putString(sKey, sObjParam); } Message msgBack = Message.obtain(null, iMsg); if (msgBack != null) { msgBack.setData(b); messenger.send(msgBack); } } catch (RemoteException e) { e.printStackTrace(); } }
From source file:Main.java
public static Message createMessage(int What, Parcelable parcelable) { Message message = new Message(); message.what = What;//from ww w .j a v a 2s.c o m Bundle data = new Bundle(); data.putParcelable(ARG_PARCELABLE, parcelable); message.setData(data); return 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;/* www. j av a2s . co m*/ Bundle bundle = new Bundle(); bundle.putInt(key, value); message.setData(bundle); handler.sendMessage(message); }
From source file:Main.java
public static Message getMessage(int statusCode, byte[] responseBody) { Message message = new Message(); message.what = statusCode;/* w w w.j a v a 2 s. c o m*/ Bundle bundle = new Bundle(1); bundle.putByteArray("response", responseBody); message.setData(bundle); return message; }
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 ww . j av 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 sendMsg2Client(int iMsg, int arg1, int arg2, Bundle extras) { if (mMessenger == null) { return;/*from w w w . j ava 2s . co m*/ } try { Message msgBack = Message.obtain(null, iMsg); if (msgBack != null) { msgBack.arg1 = arg1; msgBack.arg2 = arg2; msgBack.setData(extras); mMessenger.send(msgBack); } } catch (RemoteException e) { e.printStackTrace(); } }
From source file:com.hat.tools.HttpUtils.java
public static void SendRequest(String url, Handler handler) { HttpGet request = new HttpGet(url); HttpClient httpClient = new DefaultHttpClient(); byte[] data = null; InputStream in = null;//from w w w.j a v a2s .c om try { HttpResponse response = httpClient.execute(request); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { ByteArrayOutputStream out = new ByteArrayOutputStream(); in = response.getEntity().getContent(); byte[] buf = new byte[1024]; int len = 0; while ((len = in.read(buf)) != -1) { out.write(buf, 0, len); } data = out.toByteArray(); Message msg = new Message(); msg.what = HTTP_FINISH; Bundle bundle = new Bundle(); bundle.putByteArray("data", data); msg.setData(bundle); handler.sendMessage(msg); out.close(); } } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try { if (in != null) in.close(); } catch (IOException e) { e.printStackTrace(); } } }