I am wondering if there is a syntax to print out something in the eclipse console windows. This is just like NSLog in xcode. Thank you
Use the android.util.Log
class http://developer.android.com/reference/android/util/Log.html.
For example:
import android.util.Log;
class Someclass {
private static final String TAG = "Someclass";
...
public boolean someMethod(int argument) {
Log.i(TAG, "This is some information log");
if (argument == 0) {
Log.e(TAG, "Error argument is 0!!!");
return false;
}
Log.w(TAG, "Warning returning default value");
return true;
}
};
The reason the TAG variable is assigned like that instead of something like:
Somelcass.class.getSimpleName()
is because the reflective method will cause the reflection metta data of the class to be loaded on initialisation, however, the 'preferred' method by android developers prevents that and hence saves CPU and initialisation time.
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