Android System Architecture
- Linux kernel Linux kernel layer is a layer of various hardware devices Android provide the underlying drive.
- The system runtime layer provides the main characteristics of the support, as well as the core Java libraries for Androin system through a number of C / C ++ libraries
- Application Framework API layer provides a variety of building applications when
- Various applications installed application layer
Four components
- Activities (Activity) Android applications, the visible parts are on the move
- Service (Service) running in the background, even if the application is still running exit
- Broadcast receiver (the BroadcastReceiver) receiving a broadcast message from the broadcast message around and send out
- A receiver to share information between the content (the ContentProvider) applications
Android Studio project directory Comments
.gradle automatically generated files without manually editing
.idea automatically generated files without manually editing
app project and detailed code resources
build automatically generated when compiling files
gradle gradle wrapper configuration file
.gitignore version control
build.gradle Global gradle build script
gradle.properties global gradle profile
gradlew / gradlew.bat gradle command executed in the command line interface
xxxxx.iml automatically generated a file without modification
local.properties Android SDK specified path in this machine
settings.gradle all modules in a given project introduced
In addition to the app directory, most files and directories are automatically generated, without modification, app contains all the source files.
build automatically generated when compiling files,
Libs project to use third-party jar package
androidTes used to write Android Test Test Case
java place to put all of our Java code
res used in the project to all the pictures, layout, strings and other resources
AndroidManifest.xml whole Android project profile
test test case for writing Unit Test
.gitignore the specified directory or file within the app exclude version control module
app.iml project is automatically generated file
This is the app build.gradle modules build scripts gradle
Confusing rules proguard-rules.pro designated project code
For resources res folder, referred to by the two methods
// define string a program name, located in res / values / strings.xml file
<resources>
<string name="app_name">HelloWorld</string>
</resources>
By code
R.string.app_name
XML by
@string/app_name
Detailed file build.gradle
Android Studio is the use Gradle to build the project. There are two build.gradle project file, a directory is in the outermost layer, one in the app directory. These two documents to build Android Studio projects have played a vital role
// outer layer build.gradle file
buildscript {
repositories {
google()
JCenter ()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
allprojects {
repositories {
google()
JCenter ()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Closure of two repositories are declared jcenter () line configuration, it is a code hosting repository, it will choose the Android Open Source Project code hosted on jcenter, dependencies closure using a Gradle plugin classpath declared, finally part of the face is the version number of the plug-in. build.gradle files in the directory outermost layer of analysis is over, you do not need to modify the contents of this file normally, unless you need to add some global project build with.
// inner build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 29 // specify the project compiled version
buildToolsVersion "29.0.2" // specify the project build
defaultConfig {
applicationId "com.example.testapplication" // Specify project package name
minSdkVersion 15 // minimum compatible version
targetSdkVersion 29 // has been done in the detailed test version
versionCode 1 // specified item version
versionName "1.0" // specified item version name
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
{buildTypes // specified installation file generated configuration
release {
minifyEnabled false // whether or not to code obfuscation
proguardFiles getDefaultProguardFile('proguard-android-optimize.
txt '),' proguard-rules.pro rule file when the 'confusion //
}
}
}
{Dependencies // dependencies specified item
// declare a local jar at all dependent libs added to the project
Implementation FileTree (the dir: 'libs', the include: [' * .jar ' ])
// declare the remote dependencies
implementation' androidx .appcompat: AppCompat: 1.0.2 '
Implementation ' androidx.constraintlayout: constraintlayout: 1.1.3 '
// declare test library
testImplementation' JUnit: JUnit: 4.12 '
androidTestImplementation ' androidx.test: Runner: 1.2.0 '
androidTestImplementation ' androidx. test.espresso: Espresso-Core: 3.2.0 '
}
Log logging tool
Android logging tools is the Log (android.util.Log).
- Log.v (). For printing those most trivial, meaning a minimum of log information. verbose
- Log.d (). For printing some debugging information, debug
- Log.i (). For printing some of the more important data, info
- Log.w (). For printing warning messages, warn
- Log.e (). For error Print program, error
//举例
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
switch (requestCode){
case 1 :
if(resultCode == RESULT_OK){
String returnData = data.getStringExtra("data_return");
Log.d("MainActivity",returnData);
}
break;
default:
}
}
Note: not recommended for use System.out.println () method! The method of printing log can not control, when the printing
Inter can not be determined, you can not add filters, logs are no tiers.