Pro Android Learning Note (ii): Development environment: Basic concepts, connecting real devices, life cycle

Source: Internet
Author: User

In the Android Learning Note (ii): The installation environment already has the appropriate content. See what is new. This is on the source website of the Android frame composition, and the standard chart no difference, but this picture is more beautiful color, recorded. This note mainly covers the Android development environment.

Some basic concepts

View. View is the UI Foundation building element. View is also available as a view container, which is hierarchical nesting. All the UI you see is view.

Activity. Activity is usually a screen of the application, usually containing one or more view (though not required), as the name implies, is to help the user to deal with a thing. Applications typically have multiple activity.

Fragment. Similar to sub-activity. An activity can display one or more fragment on the screen.

Intent. Intention to do something, it is rich in concept meaning, I think the study (a) is very good, intent is a process and inter-process wake-up component mechanism. It can broadcast messages, turn on the service, start acitivity, call up the system application (display the page, display the contact list, dial the number, answer the phone, etc.). The system also uses intent to alert the application of specific events, such as SMS, to occur.

Content Provider. Android defines a shared data mechanism standard that supports data sharing within and between applications, hiding specific storage, structure, and implementation.

Service. Background process. Android offers two services, local services can only be accessed by the app, and remote service can be accessed by other apps on the device.

Using the simulator AVD

Connect real-world devices

The Android emulator provides a good debug target, but the better way is to use the real device. I have a development environment under both Linux and Windows. Windows is simple, take Samsung phone for example, when you connect USB and open the developer USB Debugging mode, automatically install new hardware, it can be recognized. After installation, the command line is followed to see if the recognition was successful.

But I have a mobile phone to windows,360 is called, in case of a commissioning mode, do not know whether it will do bad things, all still in the Linux bar. Linux is to be set up for USB.

1, add the attached equipment in the/etc/udev/rules.d/51-android.rules instructions, the following is an example of this file. The factory ID can be queried in Http://developer.android.com/tools/device.html#VendorIds.

$ cat 51-android.rules
# # HTC
subsystem== "USB", attr{idvendor}== "0bb4", mode= "0666", owner= "Wei"
# # Samsung
subsystem== "USB", attr{idvendor}== "04e8", mode= "0666", owner= "Wei"
# # ZTE
subsystem== "USB", attr{idvendor}== "19d2", mode= "0666", owner= "Wei"
# # Huawei
subsystem== "USB", attr{idvendor}== "12d1", mode= "0666", owner= "Wei"

2. Restart Udev as follows. If your phone has been connected to the computer with the USB commissioning mode turned on, it is recommended to reseat the USB cable.

$ sudo/etc/init.d/udev Restart

3, can also use $ADB Devices command to view the connection situation

[Email protected]:~/developer/adt-bundle-linux-x86-20130522/sdk/platform-tools$ ./ADB devices
List of devices attached
hc27kmg00987 Device

The application can be deployed directly in eclipse. Android is a platform designed for developers.

Life cycle

Android Each app is a process that has its own virtual machine object to ensure secure storage protection. The system determines which application shuts down when resources are tight by applying priority level control.

Android provides seamless switching of applications for small screens, which also leads to complex application lifecycle management, such as when you switch from app A to app B, you need to save A's data, and when you return to app a from app B, the user can continue with the original operation. This is actually about how the multi-process works on mobile phones with limited resources. Recommended Review Android Learning notes (33): Activity life cycle.

Although the state is many, but also very good memory. To differentiate between a visual and an interactive state. If there may be a frame, notice, etc., blocking the activity part, activity can not interact, but still in the visual state. That is, the activity is in the foreground, but may not be the top one, not necessarily interacting with the user. In general, just dealing with oncreate (), Onresume (), and OnPause () can be, not exactly, describing three of the states that are starting, active, inactive, respectively.

When any activity in the app starts, you get the context of the app.

Commissioning

Logcat is the most commonly used commissioning tool, set up with Android---Logcat, Windows---Show View, and more. Logcat Print commissioning information, there are LOG.E,LOG.W,LOG.I,LOG.D,LOG.W a total of 5 levels, you can set different tags, Log filtering in large projects, very useful, in writing small programs, also try to develop good habits. In the Logcat window, you can also display System.out.println ().

ERROR, WARN, INFO, DEBUG, verbose is the 5 level of log, as the name implies, the priority level from high to low. Because log also consumes system resources, the general verbose is used only in the development process and should not be compiled into the last published application. Debug is compiled into the application, but does not run unless the device is in debug commissioning state. Error, warn, and info are kept running. Be good at using these levels.

Wei: in Android Reference wrote: Verbose should never be compiled to an application except during development. Debug logs is compiled in and stripped at runtime. Error, warning and info logs is always kept. My understanding is that Android can be processed according to the level of the resource optimization, verbose will not be compiled into the release of the APK, and debug can be compiled into, but only in the phone in debug mode only to run, the general operating situation will not be executed. The error,warn,debug as normal log information will also be processed in the normal running state. However, from the information on the Internet, LOG.V and LOG.D in the actual situation and this description is different, and as a bug to escalate. For security reasons, verbose should be manually removed before the official release (add a switch and many other ways to inherit the Log class, etc.), and for Debug, you can use the if (buildconfig.debug) log.d (...) To be processed. Buildconfig is an automatically generated file, similar to R.java, that can be used for: if (buildconfig.debug) {Write code that runs only in Debug mode}. This requires ADT V17 or later.

RELATED Links: My Android development related articles

Pro Android Learning Note (ii): Development environment: Basic concepts, connecting real devices, life cycle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.