/** *title: Summing up the study results from yesterday afternoon to this morning *author:zsg*date:2017-8-13/
First, learn about Android
1. Android Architecture
Android can be broadly divided into four tiers: Linux kernel layer, System runtime layer, application framework layer, application layer.
Linux kernel layer: A variety of low-level drivers: such as Bluetooth driver, WiFi drive, etc.
System Runtime Layer: Provides major feature support for Android systems. such as SQLite provides database support.
Application Framework layer: various APIs.
Application layer: All apps on the phone.
2. Android Development Features
A, four components:
Activity activities: see everything in the event
Service services: Exiting the app can still run
Broadcast receiver broadcast receiver: accepts sending broadcast messages, such as phone messages
Content provider Provider: Inter-Program Data sharing
B. Enrich system components
C, SQLite database
D, the powerful multimedia
E, location positioning
。。。。。。
Second, the development environment configuration
1, JDK installation (this I will not say, the URL on the right, the next step next, environment variables please knock Niang)
2, development tools (I use the Android Studio, link to the bottom of the blog post, pickup)
Android Studio Installation:
Next by next!
III. Create a new Android project
Start as and download the SDK (Development Kit) for the first time.
After launch, the interface is roughly the same, the left side is the project that the blogger has already built, the articles explain the above
Select Start ... to create a new Android project
Select App Run platform
Select Activity Style
Set activity-related information
finish!!!!!
Iv. running the first Android project
Create simulator, I've got one here, no we can click on the bottom left corner to create a
There's a lot of equipment for us to choose from.
Click Next, here you can choose the operating system of the application, here choose android 7.0
Here we confirm the configuration of the simulator, such as name, resolution, screen and so on, we keep the default, finish is created.
Next, you can see one more emulator in the emulator list
Click the triangle button on the right to start the simulator
The simulator starts and we can do it at will.
Below we run our first Android program on the emulator, like the label on the as toolbar, the hammer on the left is used to compile the project,
The middle of the selection to run the project, the right triangle button to run the project, we click the Triangle button, pop up the following selection box:
You can see the simulator we just created online, we choose Click OK, and then the project runs to the simulator.
Five, the Project Engineering directory analysis
Switch project mode to project
1. Gradel and. Idea
As auto-generated without manual editing
2. App
Code, resources are placed in this directory, and development is based on this directory
3. Build
Mainly contains the files generated by the compilation
4, Gradle
Include Gradle configuration file
5,. Gitignore
Specify directories or files that are excluded from version control
6, Build.gradle
Project Global Gradle Build script
7, Gradle.properties
Gradle configuration file for Project global
8, Gradlew and Gradlew.bat
The command line interface executes the Gradle command, which is used gradlew.bat in Windows systems
9, *.IML
Project is automatically generated without modifying any of the contents
10, Local.properties
Develop an SDK path in this machine
11, Settings.gradle
Specifies all referenced modules in the project, usually automatically completed
The app expands the directory structure as follows:
1. Build
Similar to the outer build, containing automatically generated files at compile time
2, Libs
Third-party jar packages, the jar packages in this directory are automatically added to the build path
3, Androidtest
Writing Android test case
4. java
Where all Java code is stored
5, Res
Resource Directory
The picture is placed in the drawable directory
Layouts placed in the layout directory
The string is placed in the values directory
No catalogs we can create our own
6, Androidmanifest.xml
The entire project configuration file, all four components defined in the program are to be registered in this file
7. Test
Used to write the unit test test case
8,. Gitignore
Similar to the Gitignore effect of the outer layer.
9, APP.IML
Project is automatically generated, do not care
10, Build.gradle
Gradle build script for app module
11, Proguard-rules.pro
Specify obfuscation rules for project code
Vi. How the Project works
Open Androidmanifest.xml, which exists as follows
1 <ActivityAndroid:name=". Mainactivity ">2 <Intent-filter>3 <ActionAndroid:name= "Android.intent.action.MAIN" />4 5 <categoryAndroid:name= "Android.intent.category.LAUNCHER" />6 </Intent-filter>7 </Activity>
This code indicates that mainactivity is registered for this activity, and no activity that is registered in Androidmanifest.xml is not available. One of the <action android:name= "Android.intent.action.MAIN"/> and <category android:name= " Android.intent.category.LAUNCHER "/> said Mainactivity is the main activity of this project, click on the app icon on the phone, start this activity first.
The following opens the Mainactivity activity with the following code:
1 public class mainactivity extends appcompatactivity { Span style= "COLOR: #008080" >2 3 @Override /span>4 protected void OnCreate (Bundle savedinstancestate) { 5 super .oncreate ( Savedinstancestate); 6 Setcontentview (r.layout.activity_main); 7 } 8 }
First, mainactivity inherits from Appcompatactivity, This is a backward compatible activity.activity is an active base class provided by Android, and all activities that inherit it or its subclasses can have active properties, so I can tell that Appcompatactivity is a subclass of activity. You can then see that there is an overridden OnCreate () method in Mainactivity, which is the method that an activity must execute to be created. There are two lines of code, the first line represents the OnCreate () method that invokes the parent class, and the second row calls the Setcontentview () method, which indicates that a layout called Activity_main is introduced to the current activity.
The Android program is designed with logical and view separation, so it is not recommended to write the interface directly in the activity, and then we open the layout file with the following code:
1 <?XML version= "1.0" encoding= "Utf-8"?> <!--Specify the version and encoding of the file--2 <Android.support.constraint.ConstraintLayout3 xmlns:android= "Http://schemas.android.com/apk/res/android"4 Xmlns:app= "Http://schemas.android.com/apk/res-auto"5 Xmlns:tools= "Http://schemas.android.com/tools" <!--These two lines can be interpreted as grammar files, prompting function --6 Android:layout_width= "Match_parent"7 Android:layout_height= "Match_parent" <!--activity width, height match_parent fill_parent fill the parent class warp_content fit Content- -8 Tools:context= "Com.example.zhangshuaige.myapplication.MainActivity"> <!--specify context for rendering--9 Ten <TextView <!--display text controls-- One Android:layout_width= "Wrap_content" A Android:layout_height= "Wrap_content" <!--width height -- - Android:text= "Hello world!" <!--displayed text-- - App:layout_constraintbottom_tobottomof= "Parent" the App:layout_constraintleft_toleftof= "Parent" - App:layout_constraintright_torightof= "Parent" - App:layout_constrainttop_totopof= "Parent" - /> + - </Android.support.constraint.ConstraintLayout> +
OK, the first Android app is here, come on.
The above knowledge mainly comes from reading the first line of code (there is a link in the previous blog post) and beginners tutorial learning. Thanks to all who share knowledge!!
Android Learning note One of the first Android programs