public void run() {
    try {

      TransferActivity.bdt.createServer();
      XML info = new XML();
      byte[] receive = TransferActivity.bdt.read();
      Log.i(TAG, "1");
      String xml = info.productSentenceXML("转账成功");
      Log.i(TAG, "2");
      TransferActivity.bdt.write(xml);
      Log.i(TAG, "3");
      Message msg = handler.obtainMessage();
      msg.what = 1;
      Log.i(TAG, "4");
      msg.obj = receive;
      Log.i(TAG, "5");
      msg.sendToTarget();
      try {

        TransferActivity.bdt.close();
      } catch (Exception e) {
        Log.i(TAG, "已关闭连接");
      }
      Log.i(TAG, "7");

    } catch (Exception e) {
      Message msg = handler.obtainMessage();
      msg.what = 0;
      msg.sendToTarget();
      TransferActivity.bdt.close();
    }
  }
Ejemplo n.º 2
0
  public void run() {
    while (true) {
      try {

        TransferActivity.bdt.createServer();
        XML info = new XML();
        byte[] receive = TransferActivity.bdt.read();
        String xml = info.productSentenceXML("转账成功");
        TransferActivity.bdt.write(xml);
        Message msg = handler.obtainMessage();
        msg.what = 1;
        msg.obj = receive;
        msg.sendToTarget();
        while (TransferActivity.bdt.isAlive()) yield();

      } catch (Exception e) {
        Message msg = handler.obtainMessage();
        msg.what = 0;
        msg.sendToTarget();
        TransferActivity.bdt.close();
      }
    }
  }