(7 Android) Android Studio project commissioning

1 active commissioning (Toast and Logcat)

android.widget.Toast class implements message alert, which information is displayed automatically disappear after a few seconds. Toast can be seen as a message box will go away, it can only be by way of program code design. Toast class definitions and the main method shown in FIG.

4.png

Toast the static method makeText (Context, CharSequence, int) is used to create a Toast object. Wherein the first parameter is a context object in the display indicates which of Activity in; the second parameter is the character string information to be displayed; the third parameter is the length of the display, or may use a class constant Toast.LENGTH_LONG Toast.LENGTH_SHORT, You may also be used in positive integer milliseconds.

Typically, the first use makeText () method creates a Toast objects, and then use the show () method to display an Activity. Before using the show () method may also be used setGravity () method sets the display position on the screen.

Toast example class is used as follows:

5.png

  • Android will generate some log (Log) information system to run the application, in accordance with the level from low to high order, which in turn are divided into Verbose (detailed), Debug (debug), Information (information), Warning (warning) and Error ( error) and other different levels. If a logical error occurs when the program is running Android, the results should not get, you can arrange some log output in the program, in order to locate the wrong location.

  • Log Android is a class, static methods produce different levels of log information, as shown in FIG.

6.png

Wherein the first parameter is a user-defined filtering convenient label, the second parameter is the information required to be output.

  • Logcat Android browser is a log provided, output log information generated when the program is run Logcat to the console, so that the positioning error of the application-specific observation position or operating information.

2 dynamic debugging

As with VC ++ and Visual Studio development environment such as in Android Studio environment, you can also set breakpoints, inspect variable values ​​way to check for errors, apply to procedural errors of fast and accurate positioning.

Unit Test 3

When developing an Android project, you may need to write a lot of business logic classes, its accuracy can be tested individually without having to debug the entire application. Testing is an important part of the development process, the default Android development environment integrates the JUnit testing framework that can be unit tested on the Android project.

Guess you like

Origin www.cnblogs.com/chenhanhao/p/12469765.html