@Override protected void onDestroy() { // Release the dispatcher instance and stop it. mDispatcher = null; CMessageDispatcher.shutdown(); super.onDestroy(); }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.messagemonitor); mMessageList = (ListView) findViewById(R.id.listView1); mSendButton = (Button) findViewById(R.id.btnSend); mSendButton.setOnClickListener(mBtnListener); // nikm mWebviewButton = (Button) findViewById(R.id.btnWebView); mWebviewButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(MessageMonitorActivity.this, AppHostMain.class)); } }); // Start the dispatcher and get an instance to it. try { // TODO: Get broker class name from configuration. (JWB) // CMessageDispatcher.startup(this); // CMessageDispatcher.startup(this, // "com.airbiquity.android.choreofleetmessaging.NetServerBroker", null); CMessageDispatcher.startup( this, "com.airbiquity.android.choreofleetmessaging.SerialServerBroker", null); } catch (AlreadyStartedException e) { // TODO Ignore if already started? (JWB) e.printStackTrace(); } mDispatcher = CMessageDispatcher.getInstance(); // Register the handler for all messages. mDispatcher.addChoreoMessageHandler(new MessageHandler(this), null); // FIXME -- initialize the director and dummy HMI ... this needs to be real! IcsDirector.getInstance(); dhmi = new DummyHmi(); IcsDirector.getInstance().addDirectorToHmiEventListener(dhmi); Thread t = new Thread(this); t.start(); }
public void onClick(View v) { try { mDispatcher.sendChoreoMessage( CMessage.buildMessagePacket(new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, 66, false), 0, 0, 0); } catch (Exception e) { Log.e("MessageMonitorActivity", "Error sending choreo message", e); // Ignore. } }