0

Hoping my interpretation is relevant, I am not sure whether android programming supports creating custom exceptions and using the following or whether this would be against the code styleguides and why do you think so.

"System.out.println() (or printf() for native code) should never be used. System.out and System.err get redirected to /dev/null, so your print statements will have no visible effects. However, all the string building that happens for these calls still gets executed." https://source.android.com/source/code-style.html

Jon C.
  • 13
  • 3

2 Answers2

1

If you want to log any messages to your IDE's console, consider using the Log.d or other log tags. They'll do the same thing as a System.out.println. Custom exceptions can be created and logged with this method.

http://developer.android.com/reference/android/util/Log.html

EDIT This question was answered in high detail at https://stackoverflow.com/a/2220559/4595114

Community
  • 1
  • 1
vkuo
  • 350
  • 1
  • 4
  • 21
1

Logging does exists however it's done using the Log class.

It has a bunch of methods that allow debugging to be done, you can find more info here: http://developer.android.com/reference/android/util/Log.html

But basically all you have to do is use one of the methods that are available:

Log.v() - verbose only used during debugging
Log.d() - debug
Log.i() - information 
Log.w() - warning 
Log.e() - error

All take two parameters a String TAG and a String msg (or an optional thirs parameter a Throwable) , the first one is used do identify your log from the bunch of others and the second is a log message. You will see those log messages when you run your app in android studio and log cat get's displayed automatically so all your logs will be listed there.