20172327 2017-2018-2 first line of Android first chapter study summary

Source: Internet
Author: User
Tags modifiers sqlite database jcenter

Study number 2017-2018-2 "first line of Android" the first chapter summarizes the learning contents of learning summary Textbook
-Android System Architecture:


1.Linux Core Layer

The Android system is based on the Linux kernel, which provides the underlying drivers for various hardware on Android devices, such as display drivers, audio drivers, camera drivers, bluetooth drivers, Wi-Fi drivers, power management, and more.

2. System Operation Bottom

-provides key feature support for Android systems through a number of C + + libraries

Library name function
SQLite Library Provide support for the database
Opengl/es Library Provides 3D drawing support
WebKit Library Provides support for the browser kernel


-Android Runtime Library (mainly provides some core libraries that allow developers to write Android apps using the Java language.) )
Dalvik Virtual machines (5.0 systems changed to Art run environment) enable each Android app to run in a standalone process and have its own Dalvik virtual machine instance.

3. Application Framework Layer

The core application of the various api,android that may be used to build the application is to use these APIs, and developers can use these APIs to build their own applications.

4. Application Layer

Applications are all part of this layer, contacts, SMS, games, etc. are all.


Summarize:

    • The 1 Android system architecture uses a layered architecture concept that is structured and structured to work together.
    • The 2 Android system Architecture not only recognizes the Android system from the macro level, but also gives us a direction for our learning and practice. If you're working on Android apps, you should study Android's application framework and application layer, and if you're working on Android, you should study Android's system library and Android runtime, and if you're working on Android-driven development, That should study Android's Linux kernel. In short, find the right entry point, practice the truth.
-Android App Development features:


1. Four components

    • Activities (activity)
      The façade of the Android app, whatever you see in the app, is placed in the event.
    • Services (Service)
      Can't see, running silently in the background, after exiting the app, the service is still able to continue to run.
    • Broadcast receivers (broadcast receiver)
      Allow your app to receive broadcast messages from everywhere, such as phone calls, text messages, and more.
    • Content provider (contents Provider)
      Sharing data between programs.


2. Rich system controls

    • Android provides developers with a rich system of controls that make it easy to write beautiful interfaces. You can also customize your own controls.


3.SQLite Database

    • Lightweight, fast-running, embedded, relational database. SQL syntax is supported and can be manipulated using the Android packaged API to make it easier to store and read data.


4. Powerful Multimedia

    • Music, video, recording, photo, alarm clock, etc., can be controlled by code.


5. Location targeting

    • Location positioning should be a bright spot, the Android phone built-in GPS, so go anywhere can be positioned to their own location, play a creative application, combined with map function, LBS (through the telecommunications mobile operator's radio communication network (such as GSM network, CDMA network) or external positioning methods (such as GPS Get the mobile end user's location information (geographical coordinates, or geodetic coordinates), with the support of the Geographic Information system (Foreign language abbreviation: GIS, Foreign language full name: Geographic information System) platform, provide the user with the corresponding service of a value-added business. This area has unlimited potential.
-Development environment Building tools:


1.JDK

    • The JDK is the Java language Software development toolkit that contains Java's operating environment, tools collection, base class libraries, and more.


2.Android SDK

    • The Android SDk is a Google-provided Android development Kit, which we need to use when developing Android programs by introducing the toolkit to the Android-related APIs.


3.Android Studio

    • 2013 Google launched an official IDE tool, not in the form of plugins, Android studio in the development of Android programs far more powerful and convenient than the previous eclipse.
-Analyze Android Program:


When you have finished creating, switch the project structure mode to project

1. Overall directory structure analysis


Description: In addition to the app directory, other directories are automatically generated. The content of the app catalog is the focus of our work.

2.APP Directory Structure Analysis


Description: The default effect of the program is not to write a line of code, directly deployed to the emulator run effect.

3. Define the main activity

        <activity android:name=".MainActivity">            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />                //这两句代码表示MainActivity是主活动,点击图标后首先运行此活动            </intent-filter>        </activity>


Description: This code indicates the registration of the mainactivity activity, and no activity that is registered in Androidmanifest.xml is not available.

4. Main activity Analysis

package com.example.zy.myapplication;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;public class MainActivity extends AppCompatActivity {    protected void onCreate(Bundle savedInstanceState) {        //活动被创建必须要调用下述的方法        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);    }}


Description
1. As we said before, all the things in the application that we can see are put into activities, so we must first inherit from the activity.
2. The inheritance relationship of the main activity:

3.super.oncreate (savedinstancestate) is the OnCreate constructor that invokes the parent class, which is used to create the active, Savedinstancestate is the state information that holds the current activity.

Where does 5.HelloWorld come from?
In fact, the design of the Android program is logical and view classification, it is not recommended to write the interface directly in the activity, the more common way is to write the interface in the layout file, and then introduced in the activity.

<?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.zy.myapplication.MainActivity">    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Hello World!" /></RelativeLayout>


Description: We see that there is a textview, which is an Android control that is used to display text in the layout.

6. Detailed Res directory


Description: The reason why there are so many mipmap opening folders, in fact, is mainly to allow the program to better compatible with a variety of devices.
Open the Strings.xml file under the values directory:

<resources>    <string name="app_name">My Application</string></resources>

This defines a string for the application name, and we can refer to it in the following two ways:

    • In the code by: ◇r.string.app_name
    • In the XML file through: ◇ @string/app_name


7. Detailed Build.gradle
In the AS, we build the project through Gradle. Gradle is a very advanced project building tool that uses a groovy-based domain-specific language (DSL) to declare project settings, discarding traditional XML-based, cumbersome configurations.

I. Build.gradle at the most outer end

buildscript {    repositories {        jcenter()    }    dependencies {        classpath ‘com.android.tools.build:gradle:2.1.0‘    }}allprojects {    repositories {        jcenter()    }}


Description

    • Both repositories use Jcenter (), Jcenter is a code-managed warehouse, and many Android open source projects choose to host the code on Jcenter, declaring these configurations, We can easily reference any open source project on Jcenter in the project.
    • Dependencies used Classpath to declare a cradle plugin.


Ii. Build.gradle in the app directory

apply plugin: ‘com.android.application‘android {    compileSdkVersion 25    buildToolsVersion "25.0.2"    defaultConfig {        applicationId "com.example.zy.myapplication"        minSdkVersion 15        targetSdkVersion 25        versionCode 1        versionName "1.0"    }    buildTypes { //用于指定生成安装文件的相关配置,一般有release和deubug两项。        release {            minifyEnabled false  //是否对代码进行混淆            proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘ //代码的混淆规则        }    }}dependencies { //用于指定当前项目的所有依赖关系    compile fileTree(dir: ‘libs‘, include: [‘*.jar‘])    //上着为本地依赖关系,将libs目录下*jar包添加到构建路径当中        testCompile ‘junit:junit:4.12‘    //声明测试用例库的    compile ‘com.android.support:appcompat-v7:25.2.0‘    //这是一个标准的远程依赖库格式,Gradle在构建项目时会检查是否有此库的缓存,如果没有则联网下载.添加依赖库声明:compile project(‘:helper‘),将helper依赖关系加入.}


Description

    • The first line refers to a plug-in, Com.android.application ' is an application module that can be run directly, Com.android.library is a library module that can only be run as a code base attached to other application modules.
    • Next is a large Android closure, which can be combined with the various properties of the project build.
      Compilesdkversion 25: Specifies SDK compilation using the Android6.0 system.
      Buildtoolsversion: Specifies the version of the project build tool.
    • Next is a defaultconfig closure that allows you to configure more details of the project.
      ApplicationID: The package name of the execution project
      Minsdkversion 15 Project minimum compatible Android system version
      Targetsdkversion 25 You have done a full test on that second version, and the system will launch some of the latest features and features for your application.
      Versioncode 1 Project version number
      Versionname The version name of the "1.0" project
-Visibility:


1. Private members of the parent class also inherit from the quilt class, although these private members cannot be accessed directly by member names, but can be accessed indirectly.

-Inter-Class inheritance relationship design:

1. In software design, it is necessary to study and design the staggered structure of the inheritance relationship between classes in particular carefully.

The 2.final method is often used to ensure that the method can be used in all subclasses. The final modifier can also act on the entire class. The final class can no longer be used to derive new classes.

Problems in teaching materials learning and the solving process
    • Question 1: What are the permissions modifiers and what are the roles?
    • Problem 1 Solution:


1: What is the permission modifier, what role does he have, and why he needs him;

A Java application has many classes, but some classes do not want to be used by other classes. There are data members and method members in each class, but not every data and method is allowed to be called in other classes. How can access control be achieved? You will need to use the access-rights modifier.

1. The permission modifier is used to control the visible range of the modified variable, method, class. That is, its scope of action;


There are 4 types of permission modifiers in 2:java:

1 public type;

2.public can be decorated with classes, member variables, constructor methods, method members.

3. Members that are modified by public can be called in any class, regardless of the same package or different packages,

4. Is one of the most privileged modifiers

1. Private type;
2. You can modify member variables, construct methods, member methods, and not decorate classes (this refers to external classes, regardless of inner classes).
3. Private-decorated members can only be used in the class in which they are defined and cannot be called in other classes.
1. Default type defaults;
2. Can be used to modify the class, member variables, construction methods, methods, all can use the default permissions, that is, no keywords are written.
3. The default permissions are the same as package permissions, and the elements of the same package permission are called only in the class in which they are defined, and in the same package class.
1. Protection type Protect;
2. You can modify data members, construct methods, method members, and cannot decorate classes (this refers to external classes, regardless of inner classes).
3. Members that are modified by protected can be called in the class that defines them, in the same class as the package.
4. If classes with different packages want to invoke them, then the class must be a subclass of the class that defines them.

Image:


3: There are several issues to be aware about permission modifiers;

1. Not every modifier can be decorated with a class (meaning an external class), only public and default can.

2. All modifiers can be decorated with data members, method members, and construction methods.

3. For the sake of code security, the modifier should not use as much permission as possible, but applicable. For example, data members, if there is no special need, use private as much as possible. Enhance the encapsulation of the;

4. Modifiers are decorated with "accessed" permissions.

    • Question 2:this and super references are different:
    • Problem 2 Solution:
This

This is an object of its own, representing the object itself, which can be understood as: A pointer to the object itself. The usage of this can be broadly divided into 3 types in Java:
1. Normal Direct references
This does not have to be said, this is equivalent to pointing to the current object itself.
2. The name of the member in the form of membership, with this to distinguish.
3. Reference constructor This (parameter):
Call a constructor in another form in this class (which should be the first statement in the constructor).
Super

Super can be understood as a pointer to a super (parent) class object, which refers to a parent class closest to itself. There are three ways to use super:
1. Normal Direct references
Like this, super is the parent class that points to the current object, so you can refer to the members of the parent class with Super.xxx.
2. The member variable or method in the subclass has the same name as a member variable or method in the parent class
3. Reference constructors
Super (parameter): Invokes one of the constructors in the parent class (which should be the first statement in the constructor).
The similarities and differences between Super and this:

Super (parameter): Call one of the constructors in the base class (should be the first statement in the constructor)
This (parameter): Calls another form of the constructor in this class (should be the first statement in the constructor)
Super: It refers to a member in the immediate parent class of the current object (used to access member data or functions in the parent class that is hidden in the immediate parent class, when the base class has the same member definition as in the derived class, such as super. Variable name super. member function by name (argument)
This: it represents the current object name (where it is easy to generate two semantics in the program, you should use this to indicate the current object, if the function's shape participates in the class member data has the same name, this should be used to indicate the member variable name)
The call to super () must be written on the first line of the subclass construction method, otherwise the compilation does not pass. The first statement of each subclass construction method is implicitly called super (), and if the parent does not have this form of constructor, it will be error-free at compile time.
Super () is similar to this (), except that super () calls the constructor of the parent class from the subclass, and this () invokes other methods within the same class.
Super () and this () all need to be placed in the first row within the construction method.
Although you can call a constructor with this, you cannot call two.
This and super can not appear in a constructor at the same time, because this is bound to call other constructors, the other constructors will inevitably have a super statement exists, so in the same constructor has the same statement, it loses the meaning of the statement, the compiler will not pass.
This () and super () all refer to objects, so they cannot be used in a static environment. Includes: static variable, static method, static statement block.
Essentially, this is a pointer to this object, but super is a Java keyword.
    • Question 3:java Why did the designer of the language explicitly decide not to support multiple inheritance?
    • Problem 3 Solution:


In February 1995, James Gosling published a Java white paper titled "Java Overview," which explains why Java does not support multiple inheritance.

Java removes some features that are rarely used in C + + and are often misunderstood, such as the overloads of the operator (operator overloading) (although Java still retains the overloads of the method), multiple inheritance (multiple inheritance), and extensive automatic forcing of the same type (extensive automatic coercions).

I would like to share here the definition of James Gosling for Java.
Java: A simple, object-oriented, distributed, interpretive (translator Note: Java is neither a purely explanatory nor a purely compiled language), robust, secure, architecture-neutral, portable, high-performance, multi-threaded, dynamic language.


Look at the beauty of the definition. Modern programming languages should have such a feature. What do we see defining the first feature? is simple.


This is why we have removed multiple inheritance in order to enhance the simplicity of this feature. Here's an example of a multi-inheritance diamond inheritance problem.

Tupian


There are two classes B and C that inherit from a. Suppose B and C both inherit the method of a and overwrite it, and write their own implementation. Assuming D inherits B and C through multiple inheritance, D should inherit the overloaded methods of B and C, so which one should it inherit? Is it B's or C's?


C + + often falls into this trap, although it also presents an alternative approach to solving the problem. We don't have this problem in Java. Even if two interfaces have the same method, the implemented class will have only one method, which is written by the implemented class. Dynamic load classes make it difficult to implement multiple inheritance.

Problems in code debugging and the resolution process
    • Question 1: When doing pp9.1, encountered the following problem
      Picture 115054
    • Problem 1 Solution: This is what I did to the coin class completely, in the coin class, we should change the face modifier to protected.
    • Question 2: When doing pp9.1, I chose to create an array of size 5 in the test class, but when I define it, only three are defined, so the sum value cannot be calculated at the last run.
      Image
    • Problem 2 Solution: The previous problem change the order, the next problem I set a variable B, the calculation process can be separated.
Last week's summary of the wrong quiz
  • First question: In Java, arrays is
    A. Primitive data types
    B. Objects
    C. Interfaces
    D. Primitive data types if the type stored in the array was a primitive data type and objects if the type stored in the ARR Ay is an object
    E. Strings

  • Analysis: In the NO. 245 page of the book, it is said that in Java, an array is an object that must be instantiated.
  • Second question: the "Off-by-one" error associated with arrays arises because
    A. The first array index is 0 and programmers could start at index 1, or may use a loop that goes one index too far
    B. The last array index was at length + 1 and loops iterate to length, missing one
    C. The last array element ends at length-1 and loops could go one too far
    D. Programmers write a loop, goes from 0 to length-1 whereas the array actually goes from 1 to length
    E. None of the above, the "Off-by-one" error has nothing to do with arrays
  • Analysis: The index value must be greater than or equal to 0 and less than the number of elements of the array. If there are X elements in the array, the index value is 0~x-1.

  • Third question: If an int array is passed as a parameter to a method, which of the following would adequately define the parameter Lis T for the method header?
    A. (int[])
    E I (int a[])
    C. (int[] a)
    D. (int a)
    E. (a[])
  • Analysis: A parameter is defined as a variable that is initially declared as a type parameter name. Here, the type is int[] and the parameter is a.

  • Question Fourth: Assume that BankAccount was a predefined class and that the declaration bankaccount[] Firstempirebank; has already been performed. Then the following instruction reserves memory space for
    Firstempirebank = new bankaccount[1000];
    A. A reference variable to the memory that stores all BankAccount entries
    B. Reference variables, each of the which point-to-a single BankAccount entry
    C. A single BankAccount entry
    D. BankAccount Entries
    E. Reference variables and BankAccount entries
  • Analysis: First bank account; reserve memory space for Firstentity Bank, which itself is a reference variable pointing to bankaccount[] objects. First Bank account = new bank account [1000]; instantiate bankaccount[] object is 1000 BankAccount object.

  • Question Fifth: Given the following declarations, which of the following variables is arrays?
    Int[] A, b;
    int c, d[];
    A. A
    B. A and B
    C. A and D
    UD. A, B and D
    E. A, B, C and D
  • Analysis: The first declaration declarations A and B are all arrays of int. The second declaration declares that C and D are ints, but for D, an int array. Both a B and d are arrays of int.

  • Question Sixth if A and B is both int arrays, then A = B; Would
    A. Create an alias
    B. Copy all elements of B into a
    C. Copy the 0th element of B into the 0th element of a
    D. return true if each corresponding element of the equal to each corresponding element of a (so is, a[0) is equal to B [0], a[1] is equal to b[1] and so forth) and return false otherwise
    E. Return True if A and B are aliases and return false otherwise
  • Analysis: This makes two arrays the same, so the arrays referenced by A and B are the same, so one is called another alias.

  • Question seventh: A Java Main method uses the parameter (string[] variable) So, a user can run the program and supply "command-line "Parameters. Since The parameter is a String array, however, and the user does not has to supply any parameters.
    A. True
    B. False
  • Analysis: After the Java command, anything entered at the command line will be accepted as a command-line argument. If a few words are separated by a space, then each word is stored as a separate string array element.

  • Eighth question: An array index cannot is a float, double, boolean, or String.
    A. True
    B. False
  • Parsing: An array index must be of type int, or it can be extended to a value of type int (therefore, char, Byte, and short are also allowed).

  • Nineth question: An array, when instantiated, was fixed in size, but an ArrayList can dynamically change in size when new elements is a Dded to it.
    A. True
    B. False
  • Analysis: One drawback of an array is its fixed size. Once instantiated, its size is fixed. ArrayList is a class that uses an array, which automatically creates a larger array and copies the old array into the new array, so that the ArrayList can be larger as needed. While this resolves the problem of throwing exceptions, it does result in poor performance because each time you increase the ArrayList size, you must copy from one array to another.

  • Tenth question: Just as arrays can only has a fixed number of elements, set at the time the array is declared, a parameter list also Can only has a fixed number of elements, set at the time of the method is declared.
    A. True
    B. False
  • Analysis: Java provides a special notation for variable-length parameter lists. Ellipsis (...) Used to specify a variable-length parameter list.

  • Question 11th: So long as one was only accessing the elements of a ArrayList, its efficiency was about the same as that's an array. It's only if one begins to insert or remove elements towards the front portion of a ArrayList that its efficiency deter Iorates.
    A. True
    B. False
  • Analysis: When inserting or deleting the first part of a ArrayList, a large number of element copies occur, reducing its efficiency.

Code-hosted pairing and peer review templates:
    • Blogs that are worth learning or questions:
      • Xxx
      • ...
    • Based on the scoring criteria, I scored this blog: xx points. The score is as follows: XXX
    • Something worth learning or doing in your code:
      • Xxx
      • Xxx
      • ...
    • Based on the scoring criteria, I scored this blog: xx points. The score is as follows: XXX

    • Reference example

reviewed the classmates blog and code
    • This week's study of the knot
      • 20172317
      • Pair of photos
      • Pairs of learning content
        • Xxxx
        • Xxxx
        • ...
Other (sentiment, thinking, etc., optional)

A lot of concepts, hooves look closely, there are many details, and the previous chapters are closely related.

Learning progress Bar
lines of code (new/cumulative) Blog Volume (Add/accumulate) Learning Time (new/cumulative) Important Growth
Goal 5000 rows 30 Articles 400 hours
First week 95/95 1/1 18/18
Second week 515/620 1/2 22/40
Third week 290/910 1/3 20/60
Week Four 1741/2651 1/4 30/84
Week Five 579/3230 1/5 20/104
Week Six 599/3829 1/6 18/122
Seventh Week 732/4561 1/6 24/146

Reference: Why is it so difficult to estimate software engineering applications, software engineering estimation methods

    • Planned study time: 22 hours

    • Actual learning time: 24 hours

    • Improvement: slightly.

(See more modern software engineering courseware
Software engineer Competency Self-evaluation table)

Resources
    • "First line of code Android"

    • Tutorial on Java Programming and data Structure (second edition) Learning Guide
    • Analyze the first Android application knot
    • Why Java does not support multiple inheritance

20172327 2017-2018-2 first line of Android first chapter study summary

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.