之前用MyEclipse写网页的时候,抛出异常,直接用e.printStackTrace便可以直接输出错误发生函数的调用堆栈信息。

结果到写Android的时候就不好用了,虽然代码也不报错,但是看不到在哪里输出了。

后来在stackoverlow看到一个人问在Android中用e.printStackTrace()是不是一个bad idea。

然后后面回答it is a bad idea。

(http://stackoverflow.com/questions/3855187/is-it-a-bad-idea-to-use-printstacktrace-in-android-exceptions)

有人便给出适当的操作方法:

catch (Exception e) {     Log.e(TAG,Log.getStackTraceString(e)); }
这样就能在LogCat中输出调用堆栈信息,并且也是可以点击函数跳转到错误行。

更多相关文章

  1. 【zz】安装Android的Eclipse插件ADT遇到错误“requires 'org.ecl
  2. 升级android sdk到5.0时,创建项目出现错误:No resource found that
  3. findViewById()使用常见错误
  4. E/错误(3907): android.view.ViewRootImpl$CalledFromWrongThrea
  5. [置顶] Android--纠正Activity横竖屏切换的生命周期的错误
  6. Android - 常见错误的解决方法
  7. [android]初始化代码仓库时出现“OSError: [Errno 2] No such fi
  8. Java工程中调用Android库出现“Stub!”错误
  9. Android AApt错误

随机推荐

  1. Dealing with dependencies in Android p
  2. 最新統計:44% IT 和商務人士選擇 Android(
  3. imageView 的 android:maxHeight,maxWidt
  4. RK3288 Android 7.1 屏蔽“您的设备内部
  5. android中基于网络和GPS的不同精度定位
  6. Android AppWidget系统框架
  7. Mac Yosemite下Android Studio环境问题集
  8. Android 中文 API (36) —— Toast
  9. Android 中Activity,Window和View之间的
  10. eclipse android安装