The first chapter begins with your first line of Android code

Source: Internet
Author: User
Tags sqlite database

Note : This note rhythm, strictly according to book chapters, Hope forgive me, so code will upload GitHub, especially simple, I will omit! The origin of Android, the history of Android, and its unofficial history, please Baidu, Google
     对于这种知识,个人认为知道就好...............................................
Android System Architecture
 Android 可以大致分为四层架构,五块区域。

1. Linux kernel layer 
The Android system is the base Linux2.6 core, which provides the underlying drivers for various hardware of Android devices, such as display drivers, audio drivers, camera drivers, bluetooth drivers, Wi-Fi drivers, power managers, etc.
2. System Runtime Layer 
This layer provides key feature support for Android systems through a number of C + + libraries. such as the SQLite library provides support for the database, openggl| The ES Library provides support for 3D drawings, and the WebKit Library provides support for the browser kernel.
Also on this tier are the Android runtime libraries, which provide some core libraries that allow developers to write applications in the Java language. In addition, the Android runtime contains Dalvik virtual machines, which enable each Android app to run in a separate process and have its own Dalvik virtual machine instance. Compared to Java virtual machines, Dalvik is specifically tailored for mobile devices and is optimized for mobile MEMORY,CPU performance.
3. Application Framework Layer 
The starring role is to provide some of the core applications that can be used to build the application, using these APIs, and developers can build their own applications by using these APIs. api,android
4. Application Layer
All applications installed on the phone belong to this layer, such as the system's own contacts, SMS and other programs, or downloaded from the third-party market app.

Android released version

Because Android version is developing too quickly! Here do not specify, from September 2008, Google officially released Android System 1.0 system, to write notes this day is Android 6.0

Android App Development features

1. Four Components
The four components of the Android system are active (activity), service, broadcast receiver (broadcast receiver) and content provider (ContentProvider), The activity is so the façade of the Android app, whatever you see in the app, is placed in the activity. And the service is relatively low-key, you can not see it, but it has been running silently in the background, even if the user quit the application, the service can still continue to run, the broadcast receiver can allow your app to receive all the broadcast messages, such as telephone, SMS, of course, your application can also send out broadcast messages. The content provider provides the possibility for sharing between applications, such as when you want to read a contact from a system phone book, and it needs to be done through a content provider.
2. Rich system Controls
The Android system provides developers with rich system controls that make it easy to write good-looking interfaces and, of course, custom controls.
3. SQLite database
The Andriod system comes with this lightweight, fast-computing embedded relational database. It supports standard SQL syntax and can be manipulated via the Android packaged API, making it easy to store and read data.
4. Location targeting 
Compared to the mobile device and the PC, location positioning can be regarded as a big bright spot, now the Android phone has built-in GPS, go anywhere can locate their own location, combined with powerful map function, lbs this field potential unlimited.
5. Powerful Multimedia
Android also offers a wealth of multimedia services, such as music, video, recording, photo shoot, and more, all of which can be controlled through code in the program, making your app colorful.
6. Sensor
Android phones will have built-in sensors, such as acceleration sensing, direction sensors, and so on, which is a major feature of mobile devices. By using these sensors flexibly, you can make many applications that are simply not possible on a PC.

Hand in hand to build your development environment

This book is developed using Android Studio 2.0 and you can see Android studio Getting started to master http://blog.csdn.net/yanbober/article/details/45306483

First Andriod Program
 书上的例子,Hello World! 如有需要请下载:https://github.com/RelocationTime/First_Row_Code.git
1.3.3 Analysis of your project
由于本人使用的是android studio 2.0作为开发工具,所以不对eclipse + adt  做 介绍,但是我会介绍一下一个主要的目录及文件。1. src  这个目录是放置我们所有的Java代码的地方,它这这里的含义和普通的java项目下的src目录是完全一样的2. libs   这里放置的是所有用到的libs,以后的各种开源库都放置在其中。3. res   这里面放置,我们项目里,所有要用到的资源,包括图片,各种布局,动画,选择器等等4. AndroidManifest.xm 这个目录,个人觉得是最重要的,是整个项目的配置文件,四大组件都需要注册,但在AS中会自动注册,不需要我们手动注册,还可以给应用程序添加权限声明,指定最低 兼容版本和目标版本,这个目录需要大家用心多多体验!以上四个是AS 和 Eclipse都有的,其他不做介绍,要是深入学习AS, 请百度http://blog.csdn.net/yanbober/article/details/45306483开始简单分析代码:
 PackageCom.example.rescue.firstcode;//1Importandroid.support.v7.app.AppCompatActivity;//2ImportAndroid.os.Bundle;///2.1 Public  class mainactivity extends appcompatactivity { //3    @Override    protected void onCreate(Bundle savedinstancestate) {//4        Super. OnCreate (Savedinstancestate); Setcontentview (R.layout.activity_main);//5}}

Detailed description, will not do the following:
1: Define for our Package
2: Is the class that we used in the code to import
3: Is our main class, Java syntax will not, please bypass, extends inherit the Activitiy subclass, the book is inherited activity, here is used as the environment, essentially the same, are the activity of the sub-class
4: Is the method we must rewrite
5: We set the layout of the page display, it can be understood to show what the interface is placed on our mobile phone page, R.layout.activity_main, what is it? Below we introduce

<?xml version= "1.0" encoding= "Utf-8"?><Relativelayout xmlns:android="Http://schemas.android.com/apk/res/android"    Xmlns:tools="Http://schemas.android.com/tools"    Android:layout_width="Match_parent"    Android:layout_height="Match_parent"    Android:paddingbottom="@dimen/activity_vertical_margin"    Android:paddingleft="@dimen/activity_horizontal_margin"    Android:paddingright="@dimen/activity_horizontal_margin"    Android:paddingtop="@dimen/activity_vertical_margin"    Tools:context="Com.example.rescue.firstcode.MainActivity">1<TextViewandroid:layout_width="Wrap_content"android:layout_height= "Wrap_content" android:id="@+id/tv"android:text="Hello world!" />                                2</relativelayout>

Conduct personal knowledge and explain:
XML language does not, please self Baidu, everyone just know, start tag, end tag, attribute its essential understanding, can, for example relativelayout this tag, must have its own start and end tag, as well as its properties <–
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent" ><–/>

Please read my summary after you know the book.
1. Each component must specify its width and height
2. Why some attributes are defined as "@+id/tv" and a bit of "@id/tv"
know : @+: Is their own property label, please remember that it is their own, for their own labeling, and @/is a reference to the mark, meaning that it is not their own, is quoted others, attention is someone else's! People should know the principle of @+ and @/, this is my self-study process, do not understand the place
3. ID Please do not use numbers, special symbols, capital letters, I say the best
4. What does xmlns:android= "http://schemas.android.com/apk/res/android" mean? It is the domain name space of XML, we learn a bit about XML knowledge, understand, I just hint

The function of the log tool

  The log is important, it's important , it's important.
Through the previous section of the study, we should be successful to create their own first program, the directory structure, running process also have a certain understanding, perhaps a little do not understand, but it does not matter, slowly, with the code of continuous practice, you will be skilled, refueling!

Introduction to the Log

LOG.V ()
V:verbose: Long, wordy, cumbersome, is its English meaning, it is the grade, is the lowest, the printing thing, is the long, and so on, cumbersome to
LOG.D ()
D:debug: Debugging information; Insect removal; Diagnosis is its English meaning, higher than verbose, used to print some debugging information, it is useful.
LOG.I ()
I:info, the English meaning of information, printing is more important, can help you analyze the user behavior of the kind, higher than the debug level.
LOG.W ()
W:warn: Warning of the English meaning, this is the hint program in this place there will be a potential risk, it is best to fix the warning place, higher than info.
LOG.E ()
E:error: Wrong Meaning, this is the task that must be dealt with, there is a serious problem that causes the program to not run

Precautions :
1. How to print below Eclipse Logcat, it must be the device loses focus, or the simulator is out of line
Resolution: Enter the DDMS view and click on the current device in the Devices window to
 
2. [2016-01-06 14:11:18-note] The connection to ADB are down, and a severe error have occured.
[2016-01-06 14:11:18-note] You must restart ADB and Eclipse.
[2016-01-06 14:11:18-note] Please ensure that ADB was correctly located at ' D:\Users \lyp\appdata\local\android\sdk\platform-tools\adb.exe ' and can be Executed.
This problem is very common and is essentially the port occupied by the ADB device, the workaround that can be seen in my other blog: blog.csdn.net/android_lyp/article/details/50469031

3. Why log is used instead of using System.out
In fact, I was, especially like to use SYSO, because I Java Foundation is very good, is good at debugging, but slowly, I like on the Logcat, the reason is very simple, logcat strong, will be better than syso too much, we slowly use, you will have a deep understanding

End of Chapter I.

The first chapter begins with your first line of Android code

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.