Leos Literak
Leos Literak

Reputation: 9484

Why Android doc uses System.out

I copied a sample from MotionEvent javadoc. It did not print anything to logcat so i looked more deeply and realized that it uses System.out instead of Log. Is it a bug in Javadoc or did I miss something and is it supposed to print somewhere I can see?

void printSamples(MotionEvent ev) {
 final int historySize = ev.getHistorySize();
 final int pointerCount = ev.getPointerCount();
 for (int h = 0; h < historySize; h++) {
     System.out.printf("At time %d:", ev.getHistoricalEventTime(h));
     for (int p = 0; p < pointerCount; p++) {
         System.out.printf("  pointer %d: (%f,%f)",
             ev.getPointerId(p), ev.getHistoricalX(p, h), ev.getHistoricalY(p, h));
     }
 }

Upvotes: 0

Views: 37

Answers (1)

laalto
laalto

Reputation: 152867

System.out is a PrintStream and provides handy helpers such as printf() that Log does not. Also on many configurations, System.out is redirected to Log with log level INFO. This is just guessing but probably these are some of the reasons why the original snippet uses System.out.

You are free to replace the System.out.printf(...) calls with android.util.Log.i("sometag", String.format(...)) to get similar output in logcat.

Upvotes: 2

Related Questions