为什么Android doc使用System.out

时间:2015-12-15 21:18:08

标签: android

我从MotionEvent javadoc复制了一个样本。它没有打印任何东西到logcat所以我看得更深,并意识到它使用public class NotificationActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Check if the app was already running if (isTaskRoot()) { // App wasn't running, so start the app from the beginning Intent startIntent = new Intent(this, MyStartingActivity.class); startActivity(startIntent); } else { // App was already running, bring MainActivity to the top Intent reorderIntent = new Intent(this, MainActivity.class); reorderIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(reorderIntent); } // We are done now so just finish finish(); } } 而不是System.out。它是Javadoc中的一个错误还是我错过了什么,它应该打印在我能看到的地方吗?

Log

1 个答案:

答案 0 :(得分:2)

System.out是一个PrintStream,提供printf()的{​​{1}}等便捷助手。此外,还有许多配置Log is redirected to Log with log level INFO。这只是猜测,但可能这些是原始代码段使用System.out的一些原因。

您可以使用System.out替换System.out.printf(...)次调用,以便在logcat中获得类似的输出。