List of usage examples for android.os Message obtain
public static Message obtain(Handler h, int what)
From source file:org.scratch.microwebserver.MicrowebserverService.java
void disconnectDispatcher() { // If we have received the service, and hence registered with // it, then now is the time to unregister. if (dispatchConn != null) { try {/*from ww w . j ava2 s .c o m*/ Message msg = Message.obtain(null, MessageTypes.MSG_SERVER_BYE.ordinal()); msg.replyTo = mMessenger; disptachMessenger.send(msg); } catch (RemoteException e) { //HANDLE !!! // There is nothing special we need to do if the service // has crashed. } // Detach our existing connection. unbindService(dispatchConn); } }
From source file:pl.poznan.put.cs.ify.app.MainActivity.java
public void requestActiveRecipesList() { if (mService != null) { Message msg = Message.obtain(null, ServiceHandler.REQUEST_ACTIVE_RECIPES); try {/*w w w.ja va 2s. c o m*/ mService.send(msg); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:by.zatta.pilight.MainActivity.java
/** * Un-bind this Activity to MyService/*from ww w . j av a2s . c o m*/ */ private void doUnbindService() { if (mIsBound) { // If we have received the service, and hence registered with it, // then now is the time to unregister. if (mServiceMessenger != null) { try { Message msg = Message.obtain(null, ConnectionService.MSG_UNREGISTER_CLIENT); msg.replyTo = mMessenger; mServiceMessenger.send(msg); } 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.nps.micro.MainActivity.java
private void unbindFromUsbService() { if (isBoundToService) { Log.d(TAG, "Unbinding nps usb service..."); // If we have received the service, and hence registered with it, // then now is the time to unregister. if (messengerService != null) { try { Message msg = Message.obtain(null, UsbService.MSG_UNREGISTER_CLIENT); msg.replyTo = messengerService; messengerService.send(msg); } catch (RemoteException e) { Log.d(TAG, "Cannot unregister client from service: " + e.getMessage()); // There is nothing special we need to do if the service has // crashed. }/* w w w . ja v a 2 s.c o m*/ } // Detach our existing connection. unbindService(usbServiceConnection); isBoundToService = false; } }
From source file:com.psiphon3.psiphonlibrary.TunnelManager.java
private void sendClientMessage(int what, Bundle data) { if (m_incomingMessenger == null || m_outgoingMessenger == null) { return;//w w w. j av a 2 s . c om } try { Message msg = Message.obtain(null, what); msg.replyTo = m_incomingMessenger; if (data != null) { msg.setData(data); } m_outgoingMessenger.send(msg); } catch (RemoteException e) { MyLog.g("sendClientMessage failed: %s", e.getMessage()); } }
From source file:pl.poznan.put.cs.ify.app.MainActivity.java
public void onServerUrlChanged() { if (mService != null) { Message msg = Message.obtain(null, ServiceHandler.REQUEST_RESTART_GROUP_RECIPES); try {/*from ww w .ja v a 2 s . c o m*/ mService.send(msg); } catch (RemoteException e) { e.printStackTrace(); } } }
From source file:ch.nexuscomputing.android.osciprimeics.OsciPrimeService.java
@Override public void startSampling() { try {/* ww w. ja v a 2 s . com*/ mServiceMessenger.send(Message.obtain(null, START)); } catch (RemoteException e) { e.printStackTrace(); } }
From source file:ch.nexuscomputing.android.osciprimeics.OsciPrimeService.java
@Override public void stopSampling() { try {//ww w . ja v a 2 s. c om mServiceMessenger.send(Message.obtain(null, STOP)); } catch (RemoteException e) { e.printStackTrace(); } }
From source file:by.zatta.pilight.MainActivity.java
/** * Send data to the service/* www. j a v a 2 s . c o m*/ * * @param intvaluetosend The data to send */ private void sendMessageToService(String switchCommand) { Log.v(TAG, "switchCommand: " + switchCommand); if (mIsBound) { if (mServiceMessenger != null) { try { Bundle bundle = new Bundle(); bundle.setClassLoader(this.getClassLoader()); bundle.putString("command", switchCommand); Message msg_string = Message.obtain(null, ConnectionService.MSG_SWITCH_DEVICE); msg_string.setData(bundle); msg_string.replyTo = mMessenger; mServiceMessenger.send(msg_string); } catch (RemoteException e) { } } } }
From source file:com.yschi.castscreen.MainActivity.java
private void doUnbindService() { if (mServiceMessenger != null) { try {//from www . j a va 2s . co m Message msg = Message.obtain(null, Common.MSG_UNREGISTER_CLIENT); msg.replyTo = mMessenger; mServiceMessenger.send(msg); } catch (RemoteException e) { Log.d(TAG, "Failed to send unregister message to service, e: " + e.toString()); e.printStackTrace(); } unbindService(mServiceConnection); } }