Learn Android 01 Basics

Source: Internet
Author: User

(All learning materials are from Mars and the first line of code)

* System Architecture:We develop on the application framework, specifically to learn how to use the classes inside, how to instantiate

* component-based application development:Events: Everything we see is put into action. It is the interface that the user interacts with.Service: Backstage, silently running, the user can't see.Broadcast Receivers: Accept radio messages from all over the place (listening to everything that happens on the phone, listening to all the actions of the system), such as the phone, the SMS, the phone is running out of power, of course we can send messages.content providers: Provides the possibility of sharing data between applications, for example, we want to read the contacts in the Address Book. It is a way to expose data to your contentprovider, and you can access your data by knowing your address. * Some other features:Rich system controls--to write the interface SQLite database--is the lightweight database Android comes with location positioning-built with GPS powerful multimedia-music,Alarm Clock, taking pictures, etc.(scientific research to be reminded of the feeling will be used to look!) )Sensors-acceleration, direction, etc. *eclipse has a few icons:First SDK manager second Android emulator third skip all breakpoints fourth for code checking* Create the first program:The first two initials are capitalized, and the project name usually does not contain a space package name like a website domain name upside down write just as other is to choose this page by the literal meaning to select the app icon to create the active interface, more different needs need to choose different activities run view HelloWorld, right-click Project- >run as->android Application*--dalvik Virtual Machine Debug Monitoring service using DDMS window (Window->open perspective->ddms)We have a device that is online, and if we find that the device is down, we can press the Triangle->reset adb
* Specific analysis procedures:Let's look at the catalog of the projectsrc:Put the CodeGen:There is a R.java, others will be automatically generated corresponding to the files in Src, remember never to manually modifyAssets:Not much to use, store files packaged with the programBin:Do not pay attention, will generate APK file, copy to the phone can be installed directlyLibs:If you use a third-party jar and put it in this folder, it will automatically be added to the build path.Res:There are a lot of directories below, the images we use (different resolutions drawable folders), Layout, menu (values), and so on, the resources are all fixed, and there are many iddrawable folders generated, are of different resolutions. In order to be compatible with a variety of devices, we may have a copy of the same diagram at various resolutions, placed in the corresponding folder, and then when the program runs automatically according to the device to choose which folder to load the diagram. Sometimes we only have one picture, and there's a direct presence.drawable-hdpiInAndroidmanifest.xml:The main configuration file, the four components need to be registered in this file. You can also add a permission statement inside, or you can reassign a compatible version, and so on Project.Properties: Set the properties of the project. Compile the SDK version used* Specific look at the code:Androidmanifest.xml files usually see the interface is placed in the activity, we see the HelloWorld interface is HelloWorld this activity we found in this file does not display the word "Hello world!" Appear.because Android is a logical and view-separated , it is not recommended to write the interface directly within the activity. This is done by writing the interface in the layout file and then introducing it into the activity.  The Res/layout/activity_hello_world.xml layout file was opened, but the word "Hello world!" was not displayed Appear.
"Hello world! "is not defined in the layout file ~Android does not recommend hard-coding strings in a program, generally defining strings in Res/values/strings.xmlThe definition of a string uses the form of a key-value pair Modify the value of the app_name to modify the name of the app.
"Hello world!" The value corresponds to a key value called Hello_world. In Activity_hello_world.xml we use Hello_world to quote. We can see how to reference the resources under Res:
1. r.string.hello_world in the code to reference 2. @string/hello_world in XML to reference
When we want to refer to the picture, we change the string into drawable, layout file is layouts ... For example, the icon for our project is under the Androidmanifest.xml file:* Print logs with Logcat:Window->show View->other...->android->logcat can open it.LOG.V ()--minimum log information, level: VerboseLOG.D ()--debug information, Level: Debug
log.i ()--important data, level: infoLOG.W ()--warning message, level: Warn
LOG.E ()--error message, Basic: ErrHit a piece of code, run the project, and the information will come out in Logcat:? More than the first red and last blue one in the book, not knowing what's going on .1. AboutError opening trace file:no such file or directory. answer fromhttp://stackoverflow.com/later asked the teacher, the teacher said these two mistakes do not matter ~

Learn Android 01 Basics

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.