List of usage examples for android.os Message obtain
public static Message obtain(Handler h, int what, Object obj)
From source file:com.chess.genesis.net.NetworkClient.java
private void login_setup() { final JSONObject json = new JSONObject(); try {// w ww .ja v a 2s . c o m try { request.put(_PASSHASH, Crypto.LoginKey(socket, request.getString(_PASSHASH))); } catch (final JSONException e) { throw new RuntimeException(e.getMessage(), e); } } catch (final SocketException e) { try { json.put(_RESULT, _ERROR); json.put(_REASON, CANT_CONTACT_MSG); socket.logError(context, e, request); } catch (final JSONException j) { throw new RuntimeException(j.getMessage(), j); } error = true; } catch (final IOException e) { try { json.put(_RESULT, _ERROR); json.put(_REASON, LOST_CONNECTION_MSG); socket.logError(context, e, request); } catch (final JSONException j) { throw new RuntimeException(j.getMessage(), j); } error = true; } if (error) callback.sendMessage(Message.obtain(callback, fid, json)); }
From source file:foam.starwisp.NetworkManager.java
private void Request(String u, String type, String CallbackName) { try {/*from ww w . j a v a 2 s . c om*/ Log.i("starwisp", "pinging: " + u); URL url = new URL(u); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setUseCaches(false); con.setReadTimeout(100000 /* milliseconds */); con.setConnectTimeout(150000 /* milliseconds */); con.setRequestMethod("GET"); con.setDoInput(true); // Starts the query con.connect(); m_RequestHandler.sendMessage( Message.obtain(m_RequestHandler, 0, new ReqMsg(con.getInputStream(), type, CallbackName))); } catch (Exception e) { Log.i("starwisp", e.toString()); e.printStackTrace(); } }
From source file:com.abhi.barcode.frag.libv2.BarcodeFragment.java
private void decodeOrStoreSavedBitmap(Bitmap bitmap, Result result) { // Bitmap isn't used yet -- will be used soon if (handler == null) { savedResultToShow = result;// ww w . j a va 2s. c o m } else { if (result != null) { savedResultToShow = result; } if (savedResultToShow != null) { Message message = Message.obtain(handler, IDS.id.decode_succeeded, savedResultToShow); handler.sendMessage(message); } savedResultToShow = null; } }
From source file:kkook.team.projectswitch.gcm.TestActivity.java
private void setTextInfo(String text) { handlerTextInfo.sendMessage(Message.obtain(handlerTextInfo, 0, text)); }
From source file:com.iwedia.adapters.FragmentTabAdapter.java
/** * When callback arrives for new events, update view. */ public void notifyAdapters(String date) { Message.obtain(mHandler, 0, date).sendToTarget(); }
From source file:co.jlabs.cersei_retailer.zxingfragmentlib.BarCodeScannerFragment.java
private void decodeOrStoreSavedBitmap(Bitmap bitmap, Result result) { // Bitmap isn't used yet -- will be used soon if (handler == null) { savedResultToShow = result;// w w w . j a v a2s . co m } else { if (result != null) { savedResultToShow = result; } if (savedResultToShow != null) { Message message = Message.obtain(handler, DECODE_SUCCEDED, savedResultToShow); handler.sendMessage(message); } savedResultToShow = null; } }
From source file:com.github.barcodeeye.scan.CaptureActivity.java
private void decodeOrStoreSavedBitmap(Bitmap bitmap, Result result) { // Bitmap isn't used yet -- will be used soon if (mHandler == null) { mSavedResultToShow = result;//from ww w. j av a 2 s. c o m } else { if (result != null) { mSavedResultToShow = result; } if (mSavedResultToShow != null) { Message message = Message.obtain(mHandler, R.id.decode_succeeded, mSavedResultToShow); mHandler.sendMessage(message); } mSavedResultToShow = null; } }
From source file:com.android.example.notificationlistener.Listener.java
@Override public void onNotificationRankingUpdate(RankingMap rankingMap) { Message.obtain(mHandler, MSG_ORDER, new Delta(null, rankingMap)).sendToTarget(); }
From source file:foam.starwisp.NetworkManager.java
private void Post(String u, String type, String data, String CallbackName) { try {/*from w ww . j a va 2 s.co m*/ Log.i("starwisp", "posting: " + u); URL url = new URL(u); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setUseCaches(false); con.setReadTimeout(100000 /* milliseconds */); con.setConnectTimeout(150000 /* milliseconds */); con.setRequestMethod("POST"); con.setDoInput(true); con.setDoOutput(true); List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("data", data)); OutputStream os = con.getOutputStream(); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8")); writer.write(getQuery(params)); writer.flush(); writer.close(); os.close(); // Starts the query con.connect(); m_RequestHandler.sendMessage( Message.obtain(m_RequestHandler, 0, new ReqMsg(con.getInputStream(), type, CallbackName))); } catch (Exception e) { Log.i("starwisp", e.toString()); e.printStackTrace(); } }
From source file:com.android.example.notificationlistener.Listener.java
@Override public void onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) { Message.obtain(mHandler, MSG_NOTIFY, new Delta(sbn, rankingMap)).sendToTarget(); }