When debugging a program, parameter output is helpful for us to know whether the entire program operates according to our own logic.
There are many methods for outputting information in the java program on the Android platform on the console:
1. System. out. println ("...");
2. android. util. Log ("...");
Now let's look at the two inputs to see how to extract the content of our only relationship, and the rest of the output will disappear on the other side of the world.
I. Write the Code:
First, check my java program:
[Python]
Package wyf. zcl;
Import android. app. Activity;
Import android. OS. Bundle;
Import android. util. Log;
Public class MyActivity extends Activity {
/** Called when the activity is first created .*/
@ Override
Public void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. main );
System. out. println ("first System. out. println ");
Log. d ("TAG", "first tag ");
}
}
Package wyf. zcl;
Import android. app. Activity;
Import android. OS. Bundle;
Import android. util. Log;
Public class MyActivity extends Activity {
/** Called when the activity is first created .*/
@ Override
Public void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. main );
System. out. println ("first System. out. println ");
Log. d ("TAG", "first tag ");
}
} Where:
System. out. println ("first System. out. println ");
Log. d ("TAG", "first tag ");
The above two lines are our current test example.
(In fact, I downloaded an example from the Internet and then imported it. The steps for importing the project file are described at the end .)
2. Open the Eclipse debugger (DDMS ):
1. open Eclipse. in the upper left corner of the interface, a plus sign is displayed. Move the mouse over the plus sign to display "open perstective". Click here:
Check the red part. In the displayed dialog box, select the <DDMS> Option and click [OK]. The program automatically jumps to the main interface of the DDMS debugger.
In the open DDMS interface, we mainly care about the red circle, that is, the [LogCat] and the [+] button below.
3. Configure the Eclipse debugger (DDMS ):
Click the "+" button under the LogCat tag on the main interface of DDMS. Here is the filter settings for the information output. My configuration is as follows:
Click Run to view the output result as follows:
In this way, the information we just want to see is output.
========================================================== ========================================================== ==============
Record question: how to import an existing project in Eclipse?
Solution: Open eclipse, [File] --> [Import...] --> [Existing Projects into WorkSpace.
Record problems: the Android requires compiler compliance level 5.0 or 6.0. Found '1. 7' instead. Please use Android Tools> Fix Project Properties is prompted.
Solution: Right-click the Project and choose> Android Tools> Fix Project Properties. Run again. If the problem persists, check Project-> Properties-> Java Compiler and confirm
Compiler compliance level is set to 1.7 and enable specific seetings.