这是个坏主意,在Android中使用异常的printStackTrace()? [英] Is it a bad idea to use printStackTrace() in Android Exceptions?

查看:535
本文介绍了这是个坏主意,在Android中使用异常的printStackTrace()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是个坏主意,在Android的例外是这样使用的printStackTrace()?

 }赶上(例外五){
    e.printStackTrace();
}
 

解决方案

是的,这是一个坏主意。你应该使用Android的内置专为这些目的而设计的日志类:<一href="http://developer.android.com/reference/android/util/Log.html">http://developer.android.com/reference/android/util/Log.html

它给你的选项来记录调试消息,警告,错误等。

Is it a bad idea to use printStackTrace() in Android Exceptions like this?

} catch (Exception e) {
    e.printStackTrace();
}

解决方案

Yes, it is a bad idea. You should instead use Android's built-in log class specifically designed for these purposes: http://developer.android.com/reference/android/util/Log.html

It gives you options to log debug messages, warnings, errors etc.

这篇关于这是个坏主意,在Android中使用异常的printStackTrace()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆