Java – How to log in to Android

How to log in to Android… here is a solution to the problem.

How to log in to Android

I’m learning android and I want to see data through the function Log.

Now I have the code:

This one works fine, Log.i works too, but I’d like to add my own log :

                XmlPullParserFactory parserCreator = XmlPullParserFactory.newInstance();
                XmlPullParser parser = parserCreator.newPullParser();

parser.setInput(text.openStream(), null);

                int parserEvent = parser.getEventType();
                while (parserEvent != XmlPullParser.END_DOCUMENT) {


   Log.i("Test1", parserEvent);
   Log.i("Test2", XmlPullParser.START_TAG);


switch(parserEvent) {
                    case XmlPullParser.START_TAG:
                        String tag = parser.getName();
                        if (tag.compareTo("link") == 0) {
                            String relType = parser.getAttributeValue(null, "rel");
                            if (relType.compareTo("enclosure") == 0 ) {
                                String encType = parser.getAttributeValue(null, "type");
                                if (encType.startsWith("image/")) {
                                    String imageSrc = parser.getAttributeValue(null, "href");
                                    Log.i("Net", "image source = " + imageSrc);

parserEvent =;


But I have a mistake :

The method i(String, String) in the type Log is not applicable for the
arguments (String, int)

Why is the second argument int? How do I use the same Log check value as in JavaScript console.log?


Unlike Javascript, Java is a strongly typed language. The compiler checks whether you have supplied a variable of the expected type to the method. In this case, the method Log.i takes two strings as arguments.

You are trying to print an int, so you need to convert it to a string. This can be done like this, for example:

Log.i("Test2", Integer.toString(XmlPullParser.START_TAG));

Before diving into Android, perhaps you should take a look at a short introduction to the Java language to get the right basics. This will save you time later.

Related Problems and Solutions