2011-04-19 67 views

回答

0

我最终编写了自己的函数来登录设备。

public static BufferedWriter out; 
    private void createFileOnDevice(Boolean append) throws IOException { 
      /* 
      * Function to initially create the log file and it also writes the time of creation to file. 
      */ 
      File Root = Environment.getExternalStorageDirectory(); 
      if(Root.canWrite()){ 
       File LogFile = new File(Root, "Log.txt"); 
       FileWriter LogWriter = new FileWriter(LogFile, append); 
       out = new BufferedWriter(LogWriter); 
       Date date = new Date(); 
       out.write("Logged at" + String.valueOf(date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds() + "\n")); 
      } 
     } 

public void writeToFile(String message){ 
     try { 
      out.write(message+"\n"); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 

SO的相关问题是here

0

Logcollector是您的选择,但您需要首先在您的设备上安装它。

同样可以通过ADB

运行adb shell logcat > your_log_file.txt从命令提示符保存活动日志。

+0

谢谢。该应用程序用于读取WiFi信号和录制强度,因此我无法在工作时将其连接到系统。关于Logcollector,有没有办法将日志存储为文件,后者是通过访问而不是邮件/短信? – primpap 2011-04-19 09:58:25

+0

然后,您必须创建您自己的日志收集器方法,或者您可以尝试更改LogCollector的代码。您可以尝试的另一种方法是将日志保存在sqllite数据数据库中,然后尝试稍后阅读它们。 – 2011-04-19 10:06:33

相关问题