I wanted to print the value of a variable on the console for my debugging purpose but system.out.println doesnt work. Please help
System.out.println and Log.d both go to LogCat, not the Console.
drawnonward is correct , you may refer this link for more information : http://developer.android.com/resources/faq/commontasks.html#logging
toast is a bad idea, it's far too "complex" to print the value of a variable. use log or s.o.p, and as drawnonward already said, their output goes to logcat. it only makes sense if you want to expose this information to the end-user...
Writing the followin code to print anythng on LogCat wrks perfectly fine!!
int score=0; score++; System.out.println(score);
prints score on LogCat....
I'm new to Android development and I've do that:
1) Create a class:
import android.util.Log; public final class Debug{ private Debug (){} public static void out (Object msg){ Log.i ("info", msg.toString ()); } }
When you finish the project delete the class.
2) To print a message to the LogCat write:
Debug.out ("something");
3) Create a filter in the LogCat and write "info" in the input "by Log Tag". All your messages will be written here. :)
Tip: Create another filter to filter all errors to debug easily.