I am very new to Android and am trying some simple log to get a random background color. I have the code and it returns an integer between 1-256, or so I think. I need to log the value to check if it's OK, but I'm not sure how to log it with Android.. I've been using System.out.println("stuff")
to log stuff in the past but I believe that's not how you're supposed to do it in Android.
I have my class:
public static int backgroundColorRandomize()
that returns
return randomRGB;
and I try to log it like this
Log.d(backgroundColorRandomize(), "value = " + randomRGB);
but I need to convert the returned value from backgroundColorRandomize
to a String in order for it to log.
I tried java's .toString
but I'm not sure I'm using it right.. Any help would be appreciated! Thanks!
Log.d("MYINT", "value: " + randomRGB);
private static final String TAG = YourClass.class.getSimpleName();
...
android.util.Log.d(TAG, String.format("value = %d. random color = %d", randomRGB, backgroundColorRandomize()));
More info:
Logging libraries: https://android-arsenal.com/tag/57
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With