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
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".
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'
Now one window will display as
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.
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 );
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.
精彩评论