Example #1
0
  @Override
  protected void onDestroy() {
    super.onDestroy();

    /* Disconnect to prevent resource leaks. */
    mClientBusHandler.sendEmptyMessage(ClientBusHandler.DISCONNECT);
  }
Example #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // facebook
    setImageViewOnCreate("/storage/sdcard0/received_image.png");
    facebook_m_handler = new Handler();
    startRepeatingTask();

    // for facebook hackathon, the next line was modified to incorporate participants as the 3rd
    // parameter.
    mListViewArrayAdapter = new ArrayAdapter<String>(this, R.layout.message, participants);
    mListView = (ListView) findViewById(R.id.ListView);
    mListView.setAdapter(mListViewArrayAdapter);

    mEditText = (EditText) findViewById(R.id.EditText);
    mEditText.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_UP) {
              /* Call the remote object's Ping method. */
              Message msg =
                  mClientBusHandler.obtainMessage(ClientBusHandler.PING, view.getText().toString());

              mClientBusHandler.sendMessage(msg);
            }
            return true;
          }
        }); // listener ends here
    HandlerThread busThread = new HandlerThread("ClientBusHandler");
    busThread.start();
    mClientBusHandler = new ClientBusHandler(busThread.getLooper());

    /* Connect to an AllJoyn object. */
    mClientBusHandler.sendEmptyMessage(ClientBusHandler.CONNECT);
    mHandler.sendEmptyMessage(MESSAGE_START_PROGRESS_DIALOG);
  }