添加LogCat:
1.点击eclipse导航栏的Windows->Show View->Other,展开Android目录,选中LogCat,点击OK
2.在HelloWorldActivity的onCreate()方法中添加一行打印日志的语句:Log.d("HelloWorldActivity","onCreate execute");
3.重新运行HelloWorld项目,右击HelloWorld项目->Run As->Android Applicatioin。等程序运行完毕,可以看到LogCat中打印信息。
添加LogCat出现的问题及解决方法集锦:
1.问题:步骤2中Log.d("HelloWorldActivity","onCreate execute");语句中Log错误,提示信息为“Log cannot be resolved”如下图:
解决方法:选择“Import 'Log' (android.util)”即可。
2.问题:步骤3中Console中显示错误: ActivityManager: Warning: Activity not started, its current task has been brought to the front
解决方法1:点击eclipse导航栏的Project->Clean,重新运行HelloWorld项目即可。
解决方法2:参考http://stackoverflow.com/questions/3781182/activity-not-started-its-current-task-has-been-brought-to-the-front