Reputation: 386
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?
Upvotes: 1
Views: 135
Reputation: 9700
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
.
Upvotes: 5
Reputation: 1526
Always use Log.i()
in order to print logs in Android.
Log.i("ID is: ", "" + clicked.getId());
Upvotes: 0
Reputation: 33
Why you aren't using the
Log.d(TAG, stirng)
instead of
System.out.print()?
Upvotes: 0