Getting to know Android


Getting to know Android

Know Android

Android originally meant “robot”. Google designed the Android logo as a green robot, indicating that the Android system is in line with the concept of environmental protection. It is a lightweight, short and powerful mobile system, and an open system for mobile phones.

Introduction to Android

The Android operating system was originally developed by Andy Rubin. It was acquired by Google in 2005 and officially demonstrated the system to the outside world on November 5, 2007.

Android system architecture

The system architecture of Android adopts the idea of layered architecture. From top to bottom, there are four layers: application layer, application framework layer, system runtime layer and Linux kernel layer.

Application layer

This layer provides some core application packages, such as e-mail, SMS, calendar, map, browser and contact management. At the same time, developers can use the Java language to design and write their own applications, which are equal and friendly with those core applications.

Application framework layer

This layer is the basis of Android application development, and developers mostly deal with it. The application framework layer includes 10 parts: activity manager, window manager, content provider, view system, package manager, phone manager, resource manager, location manager, notification manager and XMPP service. On the Android platform, developers can fully access the API framework used by the core application. Moreover, any application can publish its own functional modules, while other applications can use these published functional modules. Based on this reuse mechanism, users can easily replace various application components of the platform itself.

Runtime and Android runtime

The system library includes 9 subsystems, namely layer management, media library, SQLite, OpenGL estate, freetype, WebKit, SGL, SSL and libc.

SQLite is an acid compliant relational database management system, which is included in a relatively small C program; OpenGL (Open Graphics Library) is a specification that defines a cross programming language and cross platform application program interface (API), which is used to generate two-dimensional and three-dimensional images.

Android runtime includes core library and Dalvik virtual machine. The former is not only compatible with the function functions that most java languages need to call, but also includes Android core library, such as android.os,,, etc; The latter is a register based Java virtual machine, which mainly realizes the important functions such as life cycle management, stack management, thread management, security and exception management, garbage collection and so on.

Linux kernel layer

Android core system services depend on the Linux kernel, such as security, memory management, process management, network protocol stack and driver model. The Linux kernel is also the abstraction layer of hardware and software stack. Drivers: display driver, camera driver, flash memory driver, binder (IPC) driver, keyboard driver, WiFi driver, audio driver and power management.

Build Android development environment

Android is developed based on Java, so you need to configure the java development environment of the system first, followed by Android development environment and simulator.

Setup steps under Windows Environment:

  • Configuring the Java environment
  • Configuring the Android studio environment
  • Configuring the genymotion simulator
  • Configure the simulator to associate with Android studio

There are many excellent ways to share the specific steps online, so I won’t write it here.

R files in Android

In the process of Android learning, I often see a lot of R files, and I will encounter r file errors. Beginners like me have a headache. They neither understand nor solve it.

What is an R file?

The R file cannot be found in the default project file of Android studio. You need to switch to the project directory to view the R file.

After the Android application is compiled, it will automatically generate an R class, which contains the IDs of all RES / directories, such as the IDs of layout files, resource files and picture files (all files under values). When writing java code needs to use these resources, you can use r class to access resources through subclass + resource name or directly use ID.

R. Java files are the “glue” between active java files (such as mainactivity. Java) and resource files (such as strings. XML). It is generally not recommended to directly modify the contents of files, because modification will destroy the resource information of the whole project.

Resource call through R file

There are two situations: in Java code and in XML code.

Used in Java code

Java text:









txtName = (TextView)findViewById(;

Use in XML

adopt@xxxYou can get it

For example, get text and pictures here:

“@ + ID / string_name” expression

Some components need to be added in the layout fileIdProperty, you can use the following expression“@+id/string_name”。

Where “+” indicates that the name in isidAdd a record to the inner class of. As“@+id/button”The meaning is to add a constant named ID to the static internal class in the filebutton, the constant is the identifier of the resource. IfidIf this static inner class does not exist, it will be created.

The resource identifier generated in this way can still be“@id/string_name”Referenced in the same way.