1

我正在使用一个 MainActivity 和另一个包含一个类的 .java。

我希望能够在我的 MainActivity 内的 textView 中从排除的类中设置 Logs 或 System.out。

例如,我的类中这个方法的 System.out:

private class Util {

private static KNXNetworkLinkIP connect(InetSocketAddress isaLocalEP, InetSocketAddress isaRemoteEP)
  {
    KNXNetworkLinkIP netLinkIp = null;

    int serviceMode = KNXNetworkLinkIP.TUNNEL; // tunnel to IP router
    boolean useNAT = true; // NAT not used for PC true or false , but needed for emulator = true
    KNXMediumSettings tpSettings = new TPSettings(true); // TP1 medium

    try
    {
      // Output the local end point address

      if (m_debugOutput == true)
      {

        System.out.println("..Tunneling, NAT ignored, TP1 medium");

        // Should be the PC's VPN address

        System.out.print("..Local  EP:");
        System.out.println(isaLocalEP.getHostName() + ":" + isaLocalEP.getPort());

        System.out.print("..Remote EP:");
        System.out.println(isaRemoteEP.getHostName() + ":" + isaRemoteEP.getPort());

        System.out.print("..useNAT:");
        System.out.println(useNAT);

        System.out.println();
      }

      netLinkIp = new KNXNetworkLinkIP(serviceMode, isaLocalEP, isaRemoteEP, useNAT, tpSettings);
    }
    catch (KNXLinkClosedException e)
    {
      System.out.println("connect:KNXLinkClosedException = " + e.getMessage());
    }
    catch (KNXFormatException e)
    {
      System.out.println("connect:KNXFormatException = " + e.getMessage());
    }
    catch (KNXException e)
    {
      System.out.println("connect:KNXException = " + e.getMessage());
    }
    catch (Exception e)
    {
      System.out.println("connect:Exception = " + e.getMessage());
    }
    return netLinkIp;

  } // connect(isaLocalEP, isaRemoteEP)

}

我知道这是一个简单的问题,但我被卡住了,不知道如何实现它.....

4

1 回答 1

2

您可以使用Log.x()方法记录,然后读取系统日志,grep 只获取您的并显示,或者编写自己的记录器,将您的日志放入 ie 数据库,然后您的其他代码可以获取并显示它。

于 2012-11-07T15:45:06.773 回答