Summary Notes


Understanding of Activity:
Activity: One of the four major application components
Function : Provide an interface that allows users to operate and interact with it
Features of the component:
①It must implement a specific interface or inherit a specific class
②It needs to be configured in the configuration file. Class name
③ Its object is not created by new, but automatically created by the system
④ Its object has a certain life cycle, and its class has a callback method corresponding to the life cycle
. Where to use reflection technology: (Andriod )
a. Configure the full class name in the configuration file
b. The layout file defines the label
c. Display intent: Intent (Context context, Class c)




2. Understanding of Intent
1). Intent: between the three components of messenger (Activity, Service, BroadcastReceiver) Communication messenger)
2). Classification: ①Explicit
: operate the current application's own components ②Implicit : operate the components of
other applications :Intent(String action)//matches the action of Activity and <intent-filter> 2. Carrying data ①Extra: putExtra(String key, Xxx value) is stored in a map container inside








②With a specific prefix: setData(Uri data)//tel:123123,smsto:123123
3. Read data:
①Extra: Xxx getXxxExtra(Sting key) ②With
a specific prefix: Uri getData()


4. Use of Activity
1. Definition
a. Define a class extends Activity, and override the life cycle method
b. Use <activity> registration in the function manifest file
2. Start
a. General startActivity(Intent intent)
b. Start with callback: startActivityForResult(Intent intent, int requestCode)
rewrite: onActivityResult(int requestCode, int requestCode, Intent data)
3. End
a. General: finish()
b. With result: setResult(int resultCode, Intent data)


5. Life cycle of
Activity 1. Activity interface state:
running state: visible but also operable
paused state: visible but inoperable
stopped state: invisible, but object exists
dead state: object does not exist
onCreate(): work on loading layout and initialization
onResume(): Only after this method can enter the running state
onDestroy(); do some finishing or cleaning work before the object dies


6. TaskStack and lauchMock
1TaskStack
   In Andriod, the system uses the Task Stack (Back Stack) structure to store
   When an application starts, the system will create a corresponding Task Stack to store and manage the application's Activity object. Only
   the Activities at the top of the top task stack can be displayed in the window.
2.lauchMode:
standard :
Standard mode, each time the startActivity() method is called, a new instance will be generated
singleTop:
    if there is already a strength that is not at the top of the Activity stack, no new instance will be generated; if it is not at the top of the stack, a new instance will be generated Instance. There is only one instance of
singLeTask
    , no one is in the current Task
singleInstance:
    there is only one instance, a new stack will be created when it is created, and there cannot be other objects in this stack. Four ways to


set monitoring:
1. In Layout: android:onClaick= "Method name"
in Activity: public void method name (View v){}
2.view.setOnclickListener(new View.OnclickListener(){})
  view.setOnclickListener(this)
  view.setOnclickListener(onclickListener member variable)


7. Application contact: call and text
1. Function description:
   1. Enter the phone number, Click "Call" to enter the dial interface, and the designated number has been entered
   2. Enter the phone number, Changan "call", make a call directly (enter the dial interface)
   3. Enter the phone and SMS content, click "Send SMS" , enter the text
   message editing interface,    and
the number and content already
   exist 3.
Enter the
   content of the phone and SMS, click "Send SMS" to enter the SMS editing interface, and have your own number and content
   4. Enter the content of the phone and SMS, long press "Send SMS", and directly send the SMS to the designated
   5. Declaration of permissions (such as calling and sending text messages) 3 ). Summary:    1. Steps to implement a simple function application:  a. Appearance: Analyze the composition of the interface and define the layout file  b. Behavior: Write the implementation of the Activity     1. Load the layout file in onCreate(): setContentView(layoutId)





    2. Call findViewById to get all the view objects that need to be operated and save them as member variables
    3. Set a listener (click/long press) for the view object, and implement the response logic in the callback method
    2. Use the implicit intent to start the interface of the system application
How to find Corresponding Action string: Add the Log log of ActivityManager, and use the system application source to find the corresponding Activity.
    2. Permissions: When calling some important functions of the system, it needs to be declared




 


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325832519&siteId=291194637