码迷,mamicode.com
首页 > 其他好文 > 详细

无需ROOT就能拿ANR日志

时间:2014-05-23 12:08:36      阅读:417      评论:0      收藏:0      [点我收藏+]

标签:style   class   blog   c   code   java   

    
bubuko.com,布布扣
    File anrFile = null;
        String status = Environment.getExternalStorageState();
        if (status.equals(Environment.MEDIA_MOUNTED)) {
            File sd = Environment.getExternalStorageDirectory();
            String path = sd.getPath()+"/anrlog/" + sd_appName;
            FileReader input = null;
            FileWriter output = null;
            try {
                    File file = new File("/data/anr/traces.txt");
                    if(file.exists()){
                            input = new FileReader(file);  
                            output = new FileWriter(path + "/trace.txt");  
                            int read = input.read();          
                            while ( read != -1 ) {  
                                    output.write(read);   
                                    read = input.read();  
                            }             
                    }
            } catch (Exception e) {  
                    
            } finally {
                    try{if(null != input) input.close(); }catch (Exception e) {}
                    try{if(null != output) output.close(); }catch (Exception e) {}
            }
            
            anrFile = new File(path + "/trace.txt");
            if(!anrFile.exists()){
                    anrFile = null;
            }
        }
bubuko.com,布布扣

 

无需ROOT就能拿ANR日志,布布扣,bubuko.com

无需ROOT就能拿ANR日志

标签:style   class   blog   c   code   java   

原文地址:http://www.cnblogs.com/vijay/p/3737238.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!