我从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
答案 0 :(得分:2)
System.out
是一个PrintStream
,提供printf()
的{{1}}等便捷助手。此外,还有许多配置Log
is redirected to Log
with log level INFO
。这只是猜测,但可能这些是原始代码段使用System.out
的一些原因。
您可以使用System.out
替换System.out.printf(...)
次调用,以便在logcat中获得类似的输出。