0

My goal is to know which parts of my program is running. I usually do this by giving a "System.out.println" statement in Java. But since I am learning to develop applications in Android could someone please tell me the equivalent statement in Android. I do know that there is one statement called the "Toast.maketext().show();" but this is not working on some parts of my program.

Thank you

Vinoth
  • 1,339
  • 6
  • 23
  • 42

4 Answers4

3

Use android.util.Log, such as:

Log.i("MyClass", "This is some message");

The output is available in the logcat view of DDMS or from the command line with "adb logcat".

hackbod
  • 90,665
  • 16
  • 140
  • 154
  • Hi Hackbod, thanks for the reply. The Logcat generates a lot of statements is there any particular way through which I can identify my line – Vinoth Aug 24 '11 at 07:17
2

Use Log and to see your output of Logs enable LogCat as

Window -> Show View -> Other -> Android -> Logcat. (In eclipse)

More about Logs :

Reading and Writing Logs

Android logging

Edited :

You can make your own filter as

Let you are using Log.i("MyActivity", "Your message");

Process to create your own filter :

Goto Log view and click on 'create filter' enter image description here

Now one window will display as enter image description here

Now put your value as

Filter Name : Put any name here (This will display as tab name, as you can see in my screens TEST and TEST1.

by Log Tag : MyActivity

Left other as it is.

Now run your app and goto to Log cat. click on your own filter tab.

Community
  • 1
  • 1
Pankaj Kumar
  • 81,967
  • 29
  • 167
  • 186
  • Pankaj I am thankful for the effort you put in. I was able to understand and also get what I set to achieve – Vinoth Aug 24 '11 at 07:48
2

Its simple, declare the constant first

  private static final String TAG = "HELLO VINOTH"; 

Then use this in ur coding so thatlogcat will show the messages with ur Nmae

 Log.v(TAG,"gender value on  male button click ="+gender );
Randroid
  • 3,688
  • 5
  • 30
  • 55
1

you can use log such as private String TAG="your Activity name";

Log.d(TAG, " ################item.getCount() is################"+count );

In logcat you will get :- your Activity name ################item.getCount() is################ 4

In this way you can easily get your line.

Anu
  • 89
  • 1
  • 7