Question

I was able to print out to the log cat for debugging yesterday, but for some reason it will not show up today.

I am trying to get the id of an image button.

In my onClickListener for the button:

clicker = new OnClickListener() {
    @Override
    public void onClick(View v) {
        ImageButton clicked = (ImageButton) v;
        makeMove(clicked.getId());

        System.out.print("ID is:"+clicked.getId());
    }
};

Would there be any reason why it would not show up on LogCat? I tried to set a filter to just SystemOut but got nothing.

Have you got any tips on getting it to output?

Was it helpful?

Solution

To print into LogCat, replace System.out.print() method with Log.i(), Log.d() or Log.w() method as like below...

System.out.print("ID is:"+clicked.getId());

with

Log.i("ID is:", " "+clicked.getId());

Because, System.out.print() is designed to print in the Console and Log.i() is designed to print in the LogCat.

So, to print in the LogCat, you should use Log class and its methods. The Log class's methods maintain some TAG as their first argument which helps to sort-out printed log in the LogCat.

OTHER TIPS

Why you aren't using the

Log.d(TAG, stirng)

instead of

System.out.print()?

Always use Log.i() in order to print logs in Android.

Log.i("ID is: ", "" + clicked.getId());
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top