[Android JNI] --- Introduction to Java and Android

1 Introduction to Java

1.1 Java technology system

Technology System illustrate
Java SE (Java Standard Edition): Standard Edition The core and foundation of Java technology
Java EE (Java Enterprise Edition): Enterprise Edition A set of solutions for enterprise application development
Java ME (Java Micro Edition): small version Solutions for mobile device applications

1.2 Java version helloeworld example

// HelloWorld.java
public class HelloWorld {
    
    
	public static void main(String[] args) {
    
    
		System.out.print("Hello World");
	}
}

Compile and run as follows:
insert image description here
javac compile command, java execute command

1.3 IDEA manages the structure of Java programs

project (project, project)
module (module)
package (package)
class (class)

Note:
1>The file name must be consistent with the class name in the code
2>There can be multiple classes in a code file, but only one can be public, and the public modified class name must be the same as the file name
3>java has no header file The concept of
4> All java classes inherit the object class by default
5> Java property control protected > default > private > public

2 Introduction to Android

2.1 android studio development environment

clear concept

  • Android studio
    Android Studio directory structure:
    insert image description here

There are two categories under the project: one is app (representing app module); the other is Gradle Scripts. Among them, there are three subdirectories under the app, and their functions are as follows:
(1) The manifests subdirectory, there is only one XML file under it, that is, AndroidManifest.xml, which is the running configuration file of the App.
(2) The java subdirectory, there are three com.example.myapp packages below, the first package stores the Java source code of the current module, and the latter two packages store the Java code for testing.
(3) The res subdirectory stores the resource files of the current module. There are 4 subdirectories under res:
the drawable directory stores graphic description files and image files;
the layout directory stores the layout files of App pages;
the mipmap directory stores App startup icons;
the values ​​directory stores some constant definition files, such as string constants strings.xml , pixel constant dimens.xml, color constant colors.xml, style definition styles.xml, etc.
The following Gradle Scripts are mainly project compilation configuration files, mainly including:
(1) build.gradle, which is divided into project level and module level, and is used to describe the compilation rules of the App project;
(2) proguard-rules.pro , this file is used to describe the obfuscation rules of Java code;
(3) gradle.properties, this file is used to configure the command line parameters of the compilation project, generally no need to be changed;
(4) settings.gradle, this file configures which modules need to be compiled . The initial content is include ':app', which means that only the app module will be compiled.
(5) local.properties, the local configuration file of the project, which is automatically generated when the project is compiled, and is used to describe the environment configuration of the developer's computer, including the local path of the SDK and the local path of the NDK.

1> Use xml tags to describe the interface, and use java code to write logic
2> The app project is divided into two levels, the first level is the project, and the other level is the module
module attached to the project. Each project has at least one module, which can also be Having multiple modules
3> Generally speaking, compiling and running an app refers to running a certain module, not a certain project, because the module corresponds to the actual app

  • android sdk
    Android SDK: Android SDK is a software development kit for the Android operating system. It contains APIs, libraries, debuggers and other tools needed to develop Android applications. Various types of Android applications can be created using the Android SDK, including mobile applications, games, browser plug-ins, and more.
  • Java sdk
    Java SDK: The Java SDK is a software development kit for the Java programming language. It contains all the tools and libraries needed for Java programming, such as compiler, debugger, JRE, etc. Various types of applications can be created using the Java SDK, including desktop applications, web applications, mobile applications, and more.

After installing java sdk, the installation directory will have jdk jre jre
(java runtime environment): java program runtime environment, including the core class library required by jvm and runtime
jdk: java program development kit, including jre and tools used by developers .
Development tool: compile tool Javac.exe; run tool java.exe
jdk, jre, jvm relationship

Configure environment variables
to check whether it is installed: jave -version

  • native sdk
    Native SDK: Native SDK is a software development kit for native application development. It contains tools and libraries required for native programming languages ​​such as C++, such as compilers, debuggers, etc. Various types of native applications can be created using Native SDK, including desktop applications, games, embedded systems, etc.

Android debugging

  • Android emulator Device manager -> Create device
  • Online real machine debugging

2.2 Android architecture

insert image description here

2.3 Introduction to Android Basics

2.3.1 UI

Software design can be divided into 2 parts: coding design and UI design
Android UI consists of layout and controls

2.3.2 Layout and controls

Layout:
All elements in the layout can be composed of View and ViewGroup.
View usually draws content that users can view and interact with.
VeiwGroup is an invisible container that defines the layout structure of view and ViewGroup objects.

Layout declaration: Edit in src/main/res/layout/activity_main.xml
Load xml resource: setContentVeiw()

ComponentsTextViewEditTextButtonImageView
_
_
_
_

3. Four major components of Android

activity
service
BroadcastReceiver
ContentProvider
data storage
network programming

Guess you like

Origin blog.csdn.net/weixin_42445727/article/details/131556210