List of usage examples for android.os Message obtain
public static Message obtain(Handler h, int what)
From source file:com.zxing.qrcode.decoding.CaptureActivityHandler.java
public void quitSynchronously() { state = State.DONE;//from w w w. j a va2 s . co m CameraManager.get().stopPreview(); Message quit = Message.obtain(decodeThread.getHandler(), R.id.quit); quit.sendToTarget(); try { decodeThread.join(); } catch (InterruptedException e) { // continue } // Be absolutely sure we don't send any queued up messages removeMessages(R.id.decode_succeeded); // removeMessages(R.id.return_scan_result); removeMessages(R.id.decode_failed); }
From source file:org.altusmetrum.AltosDroid.AltosDroid.java
void doUnbindService() { if (mIsBound) { // If we have received the service, and hence registered with it, then now is the time to unregister. if (mService != null) { try { Message msg = Message.obtain(null, TelemetryService.MSG_UNREGISTER_CLIENT); msg.replyTo = mMessenger; mService.send(msg);/*w ww.j a va 2 s . com*/ } catch (RemoteException e) { // There is nothing special we need to do if the service has crashed. } } // Detach our existing connection. unbindService(mConnection); mIsBound = false; } }
From source file:com.googlecode.networklog.NetworkLog.java
void doUnbindService() { MyLog.d("doUnbindService"); if (isBound) { if (service != null) { try { MyLog.d("Unregistering from service; service: " + service + "; messenger: " + messenger); Message msg = Message.obtain(null, NetworkLogService.MSG_UNREGISTER_CLIENT); msg.replyTo = messenger; service.send(msg);/*from www . java 2 s . c o m*/ } catch (RemoteException e) { /* do nothing */ Log.d("NetworkLog", "RemoteException unregistering with service", e); } try { MyLog.d("Unbinding connection from service:" + connection); unbindService(connection); } catch (Exception e) { Log.d("NetworkLog", "Ignored unbind exception:", e); } finally { MyLog.d("Setting isBound false"); isBound = false; } MyLog.d("doUnbindService done"); } } }
From source file:com.first3.viz.download.DownloadManager.java
private void sendDownloadFailedMsg(Resource resource) { Bundle bundle = new Bundle(); bundle.putParcelable(DownloadManager.RESOURCE, resource); String failureText = getFailureText(resource); bundle.putString(FAILURE_TEXT, failureText); Message m = Message.obtain(null, MSG_STATUS_DOWNLOAD_FAILED); m.setData(bundle);//from w ww . j a va2s. c o m sendMsg(m); }
From source file:com.first3.viz.download.DownloadManager.java
private void sendDownloadSuccessMsg(Resource resource) { Bundle bundle = new Bundle(); bundle.putParcelable(DownloadManager.RESOURCE, resource); Message m = Message.obtain(null, MSG_STATUS_DOWNLOAD_SUCCESS); m.setData(bundle);/*from w ww . j a v a2 s . c o m*/ sendMsg(m); }
From source file:org.lunci.dumbthing.fragment.MainDisplayFragment.java
private void update() { sendMessageToService(Message.obtain(null, DataServiceMessages.Service_Get_All_Items_ASC)); }
From source file:com.andrewquitmeyer.MarkYourTerritory.DemoKitActivity.java
public void run() { int ret = 0;/* w w w . java2 s . c om*/ byte[] buffer = new byte[16384]; int i; while (ret >= 0) { try { ret = mInputStream.read(buffer); } catch (IOException e) { break; } i = 0; while (i < ret) { int len = ret - i; switch (buffer[i]) { // case 0x1: // if (len >= 3) { // Message m = Message.obtain(mHandler, MESSAGE_SWITCH); // m.obj = new SwitchMsg(buffer[i + 1], buffer[i + 2]); // mHandler.sendMessage(m); // } // i += 3; // break; case 0x4: //Moist if (len >= 3) { Message m = Message.obtain(mHandler, MESSAGE_MOIST); m.obj = new MoistureMsg(composeInt(buffer[i + 1], buffer[i + 2])); mHandler.sendMessage(m); } i += 3; break; // case 0x5: // if (len >= 3) { // Message m = Message.obtain(mHandler, MESSAGE_LIGHT); // m.obj = new LightMsg(composeInt(buffer[i + 1], // buffer[i + 2])); // mHandler.sendMessage(m); // } // i += 3; // break; // case 0x6: // if (len >= 3) { // Message m = Message.obtain(mHandler, MESSAGE_JOY); // m.obj = new JoyMsg(buffer[i + 1], buffer[i + 2]); // mHandler.sendMessage(m); // } // i += 3; // break; default: Log.d(TAG, "unknown msg: " + buffer[i]); i = len; break; } } } }
From source file:com.aincc.libtest.activity.flip.FlipViewGroup.java
/** * Surface ? ? ? . * * @since 1.0.0 */ public void reloadTexture() { handler.sendMessage(Message.obtain(handler, MSG_SURFACE_CREATED)); }
From source file:com.omt.syncpad.DemoKitActivity.java
@Override public void run() { int ret = 0;/* w w w. ja v a 2s.co m*/ byte[] buffer = new byte[16384]; int i; while (ret >= 0) { try { ret = mInputStream.read(buffer); } catch (IOException e) { break; } i = 0; while (i < ret) { int len = ret - i; switch (buffer[i]) { case 0x1: if (len >= 3) { Message m = Message.obtain(mHandler, MESSAGE_KICK); m.obj = new KickMsg(composeInt(buffer[i + 1], buffer[i + 2])); mHandler.sendMessage(m); } i += 3; break; case 0x2: if (len >= 3) { Message m = Message.obtain(mHandler, MESSAGE_SNARE); m.obj = new SnareMsg(composeInt(buffer[i + 1], buffer[i + 2])); mHandler.sendMessage(m); } i += 3; break; case 0x3: if (len >= 3) { Message m = Message.obtain(mHandler, MESSAGE_TOM); m.obj = new TomMsg(composeInt(buffer[i + 1], buffer[i + 2])); mHandler.sendMessage(m); } i += 3; break; case 0x4: if (len >= 3) { Message m = Message.obtain(mHandler, MESSAGE_HIHAT); m.obj = new HihatMsg(composeInt(buffer[i + 1], buffer[i + 2])); mHandler.sendMessage(m); } i += 3; break; default: Log.d(TAG, "unknown msg: " + buffer[i]); i = len; break; } } } }
From source file:com.android.example.notificationlistener.Listener.java
@Override public void onListenerConnected() { Message.obtain(mHandler, MSG_STARTUP).sendToTarget(); }