Android life cycle with intent notes

Source: Internet
Author: User

Life cycle: from birth to death

7 methods and 3 loops for the activity life cycle

Called when OnCreate () is created
Onrestart () is not visible when the call is seen
OnStart () Called when the user is visible
Onresume () Call when user can interact
OnPause () Call when user is not interactive
OnStop () Call when user is not visible
OnDestroy () call when destroying

Start-and-exit loops
Activity start OnCreate ()--OnStart ()--Onresume ()
Activity Exit OnPause ()--onStop ()--OnDestroy ()

Visible and Invisible loops
Activity not visible onPause ()--onStop ()
Activity re-visible onrestart ()--OnStart ()--Onresume ()

Loss of focus and the cycle of gain
Activity loses focus onPause ()
Activity gets Focus Onresume ()

-----------------------------------------
Intent Bridge to jump between components

Intent is divided into the following two categories:
Explicit Intent (Explicit intent)
Explicitly specify the activity to jump to
Ambiguous intent (implicit intent)
There is no direct assignment to jump to which activity filters the activity to jump through a series of filtering criteria


1.1 Clear intent jump to activity under the same package
Intent.setclass ()

1.2 Clear intent jump to activity under different packages
Intent.setclassname ("Package name of the application", "activity package name. Activity class name");
The special case is that the package name of the activity is the same as the package name of the application, and the second parameter can be abbreviated as ". Activity class Name "

1.3 Clear intent jump to activity under different applications
Intent.setclassname ("Package name of the application", "activity package name. Activity class name");
At the same time, the jump activity needs to add Action=main filter

An ambiguous intent.
There are 7 filter conditions that need to be set:
ComponentName---Component name usage is basically similar to Setclassname ()
Action--Actions
Category-Extra action
Data--(format as URI object)
Extra--Additional data
Flag--logo
Type--Data type (MIME) multimedia format data types (text, picture, audio, video)

2.1 Ambiguous intent jump to activity under the same package
The jump activity needs to be set
Intent.setaction ("Com.second");
The activity that is being jumped at the same time needs to set the intent filter in Androidmanifest.xml:
<intent-filter >
<action android:name= "Com.second"/>---arguments with set consistent action () when jumping
<category android:name= "Android.intent.category.DEFAULT"/>--cannot be omitted
</intent-filter>
2.2 Ambiguous intent jump to different packages under the Activity method ibid.
2.3 Ambiguous Intent jump to Activiy method in different applications ibid.

Android life cycle with intent notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.