Android Mobile Development Fundamentals

Chapter 1 Getting Started with Android Basics:

1.1 Introduction to Android

  1. founder
    Android was originally a mobile operating system founded by Andy Rubin (Andy Rubin)
  2. Android Architecture
  • application layer
    is a collection of core applications, all applications installed on the phone belong to this layer
  • Application Framework Layer
    Mainly provides various API s for building applications
  • Core library classes
    Contains system libraries and runtime libraries
  • Linux kernel layer
    Provides low-level drivers for various hardware of Android devices

3.Androi program structure

  • app: used to store the code and resources of the program, including many subdirectories

  • libs: used to store third-party jar packages

  • src/androidTest: code file for storing debugging

  • src/main/java: The code file used to store the program

  • src/main/res: resource files used to store programs

  • src/main/AndroidManifest.xml: The configuration file of the entire program, in this file you can configure the permissions required by the program and the four components used in the registration program
    4.Dalvik virtual machine:
    Designed by Google, a virtual machine that can run on the Android platform
    Dalvik virtual machine is a register-based architecture
    5. Management and use of resources
    !!! There can only be one root element in an XML file
    (1) Image resources

  • Call image resources through java code

//The getResources().getDrawable() method calls image resources
getResources().getDrawable(R.mipmap.ic_launcher);//Resource file that calls files starting with mipmap
getResources().getDrawable(R.drawable.icon);//Resource file that calls files starting with drawable
  • Calling image resources in XML layout file resources

(2) Theme and style resources


Theme resources are defined in the styles.xml folder under res/values

  • The sample code for setting the theme in the AndroiManifest.xml file is as follows:
  • The sample code for setting the theme in the java code is as follows:

Stored in the styles.xml folder of res.values

	<style name="">
		<item name="">
//Set the name of the control in the name of the style, and set the style of the control in the item

//In the textView control of the layout file, you can call it through @style/stylename

(3) Layout resources

  • In java code:
  • in the XML file
<include layout="R.layout.activity_main"/>

(4) String resources
Under the strings.xml folder of res.values:

	<string name="appname">
  • In java file:
  • in the XML file

(5) Color resources
Stored in the colors folder of res.values

<color name="color1">#000000</color>
  • In java file:
  • In XML:

(6) Size resources
Under the res.values ​​file, create dimen.xml

	<dimen name="dimen1">16dp</dimen>
  • in java file
  • in the xml file

1.2 Program debugging

1.2.1 Unit testing

  • Android unit testing
  • When using this method, an Android device needs to be connected, and the speed is relatively slow, which is suitable for unit tests that need to call Android API
  • Junit unit tests
  • No need to rely on Android devices, it can be run locally, with high speed, suitable for unit testing of Java code functions only

1.2.2 Use of Logcat
The log is divided into six levels, from low to high, respectively
Verbose (all logs), Debug, Info, Warning, Error, Assert (assert)
The corresponding static method is:
The colors displayed on the console are:
black, black, black, blue, red, red

Part of the XML control explanation:

android:layout_columnSpan="2"//spans two columns

The number of rows occupied by the current control:



Which of the following statements about the AndroidManifest.xml file is false (D).
A. It is the configuration file for the whole program
B. The permissions required by the program can be configured in this file
C. You can register the components used by the program in this file
D. This file can set the UI layout

Each Dalvik virtual machine instance is an independent process space, and each process cannot communicate with each other ×

Tags: Java Android programming language

Posted by greenie__ on Mon, 24 Oct 2022 13:07:27 +1030