Android's version of C#'s Console.WriteLine?
In Android, what is the best way to write to the console. In 开发者_开发技巧C# I'd use either Log4Net or just Console.Write
Check out the help pages for Android.Util.Log.
You can use:
Log.v("MyActivity", "Verbose output");
Log.d("MyActivity", "Debug output");
Log.e("MyActivity", "Error output");
Log.i("MyActivity", "Information output");
Log.w("MyActivity", "Warning output");
Log.wtf("MyActivity", "WTF output"); // This isn't a joke :)
For simple debugging, the standard Java way suffices:
System.out.println("Message");
As @Dan Dyer mentions, System.out.println(yourString);
will do fine. But don't expect it to show up in the console running the emulator. You will have to look for your output in the logcat. (There is a tab for it in eclipse if that's your development environment.)
You need to learn how to Debug in Eclipse and how to use the ADB and DDMS tools.
In order to get more details about an exception/force close you need to look for a view in Eclipse called Logcat(you will find in the DDMS perspective) there you will find a detailed traceback when/what and on what line is the issue.
For this you should read a complete article about Debugging in Android using Eclipse
(source: droidnova.com)
精彩评论