1:4 Core Components
Activity (Activities)
Is the component in the Android app that is responsible for interacting with the user
Service (services)
The service is typically run in the background, and it generally does not need to interact with the user, so the service component does not have a graphical user interface
Broadcastreceiver (broadcast receiver)
Used to receive broadcasts sent by other components in the system
ContentProvider (content Provider)
The premise of real-time data exchange between multiple applications
II: Engineering directory structure
Android stores different content in different directories according to the purpose
src folder
Store the source code written by the developer
Store the source code of the imported third party
Gen Folder
Store the code generated automatically by the system
Assets folder
Nonmedia files used in the storage program
Bin folder
Store compiled generated files and packaged files
Libs folder
Storage of third-party jar packages
Res folder
Store layout files, resource files, etc.
Androidmanifest.xml
Configuration file
The Res folder is primarily used to store various resources
drawable all kinds of picture files under relevant files.
Layout file that contains the graphical user interface under Layout.
menu to store the layout file of the menus.
Values store various data resources, such as string resources.
androidmanifest.xml file
defines the basic information for the application
defines the application package.
defines the application components.
determines the default activity.
determine API usage rights.
defines the minimum API level.
Specifies the reference library.
r.java file
Each resource has a unique ID in the R class
The R class exists with the Gen directory.
In general, you do not need to modify this class (automatically generated).
In Java source code, reference Resource button btnlogin= (button) Findviewbyid (R.id.btnlogin);
The resource @drawable/ic_launcher @string can also be referenced in the XML file/app_name
Assets Store Nonmedia File
Will not be compiled into binary, saved in the APK package as is.
is not mapped to the R class and needs to be accessed using the Assetmanager class.
You can create subdirectories.
Create the first activity
Activity is an application component:
Contains a display interface that can interact with the user
For example: taking pictures, sending emails, browsing maps, etc.
Each activity has a window
This window is usually full of screen
can also float on top of other windows than the screen
An Android application can contain one or more activity
These activity is relatively independent.
When an activity starts, the previous activity stops.
There are usually several steps to creating an activity:
Design an interface layout for this activity
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:orientation= "Vertical" >
<textview android:id= "@+id/textview1"
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
android:text= "I am a text control"/>
</LinearLayout>
You need to create a subclass of the activity class
The OnCreate () method must be implemented
public class Mainactivity extends Activity {
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
}
}
Intent is a message passed between components
Can be passed between the same application or a different application
This message is an object of the intent class that contains a set of information
action--the action to be performed or that has occurred
Action_call (string constant)
Action_main (string constant)
ACTION_SCREEN_ON (string constant)
category--indicates the type of component that should handle the current intent
Category_home (string constant)
Category_launcher (string constant)
The intent filter is used to specify intent that the component is "willing" to receive
Can contain filter criteria for the information contained in the intent
Action
Category
The intent filter is typically used to give the activity's execution conditions when configuring activity
Configuring activity in the Androidmanifest.xml file
<manifest ...>
<application ...
&N Bsp <activity android:name= "com.csg.MainActivity" android:label= "@string/app_name";
<INTENT-FILTER>
<action android:name= "Andro Id.intent.action.MAIN "/>
<category android:name= "Android.intent.category.LAUNCHER"/>
</INTENT-FILTER>
&NBSP ; </activity>,
</application>
</manifest>
The build process for Android apps is as follows:
The build process for Android apps is as follows:
1. Generate R.java file using AAPT tool
2. Compile the. java file into a. class file using the Javac tool
4. Use Dx.bat batch processing to convert many. class files to a. dex file
5. Use the AAPT tool to package resource files (including res, assets, androidmanifest.xml, etc.)
6. Build APK Installation file
The SDK directory structure is as follows:
Add-ons, there's an additional library in there.
Docs This is the Android SDK API Reference Document
Platforms is the real file for each Platform SDK
The Tools directory contains important compilation tools
Platform-tools holds some common tools, such as ADB, and AAPT, Aidl, DX and other files
Samples is the default sample project that comes with the Android SDK
Tools, the Tools folder under the SDK root, contains important
The SDK common packages are as follows:
Android.os provides basic operational services, messaging, and interprocess communication IPC.
Android.graphics is a graphics rendering package that provides graphical rendering capabilities.
Android.database contains the underlying API processing database for easy operation of database tables and data.
Android.content provides a variety of services to access data on mobile devices, programs installed on mobile devices and other related resources, as well as content to provide presentation of dynamic Data.
Android.view core user Interface framework.
Android.widget provides standard user interface elements, lists (list), Buttons (buttons), layout manager, etc., which are the basic elements that make up our interface.
Android.app provides a high-level application model for using activity.
The Android.provider provides a convenient interface for invoking the content providers provided by the system.
Android.webikit contains an API that works in series on Web-based content.
The full name of DDMS is Dalvik Debug Monitor Service
To screen a test device
View thread and heap information for a specific process
Logcat window
Broadcast status information
Analog phone calls
Send and receive SMS messages
Virtual geographic coordinates
Emulator control can be used for analog controls
Analog Call and answer calls
Analog SMS Transceiver
Simulating geographic coordinates locations
Logcat Form Introduction
The
logcat form provides the log output and query filtering in the app run
All output information of the device can be output
If it's a real machine, you need to turn on Bebug mode
Support Log Level
Filter Query Support
The Log tool class in Android is log (ANDROID.UTIL.LOG), which provides several ways for us to print the log
LOG.V ()
print the most trivial, least meaningful log information
LOG.D ()
Print some debugging information
log.i ()
for printing Some of the more important data
LOG.W ()
used to print some warning messages
LOG.E ()
For error messages in the print program
Set Filter
Android 5.0 two first program