views:

1569

answers:

6

I wanted to print the value of a variable on the console for my debugging purpose but system.out.println doesnt work. Please help

+2  A: 

System.out.println and Log.d both go to LogCat, not the Console.

drawnonward
A: 

drawnonward is correct , you may refer this link for more information : http://developer.android.com/resources/faq/commontasks.html#logging

Ravi Vyas
A: 

I think the toast maybe a good method to show the value of a variable!

daisy
A: 

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...

Jayomat
A: 

Writing the followin code to print anythng on LogCat wrks perfectly fine!!

int score=0; score++; System.out.println(score);

prints score on LogCat....

poojan9118
A: 

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.

GagleKas