The second activity starts the second activity.

Source: Internet
Author: User

The second activity starts the second activity.
Four Android Components

  • Activity
  • BroadCastReceiver
  • Service
  • ContentProvider
Create a second Activity to create 2nd activities
  • 1. Create a class to inherit the Activity
  • 2. Create a layout file as the display content of the Activity.
  • 3. register the Activity in the list file
Configuration of the configuration file
  • The newly created activity must be configured in the list file. Otherwise, the system cannot find the newly created activity and an error will be reported during display.

    <activity android:name="com.itheima.createactivity.SecondActivity"></activity>
  • As long as the following code is available, the portal activity will generate a shortcut icon

    <intent-filter>        <action android:name="android.intent.action.MAIN" />        <category android:name="android.intent.category.LAUNCHER" />    </intent-filter>
  • If the package of an Activity has the same name as the application package, the package name can be omitted, for example, android: name = ". SecondActivity"
Implicit jump of Activity redirection
  • If an Activity needs to be implicitly redirected, the following subnodes must be added to the list file:

    <intent-filter >    <action android:name="com.itheima.sa"/>    <category android:name="android.intent.category.DEFAULT"/></intent-filter>
  • The name of the action node is defined by yourself. After the name is defined, the value of this name will become the activity action. When the Activity is started implicitly, the action set in the intent must be the same as "com. itheima. sa "is exactly matched
  • <Data android: scheme = "" android: mimeType = ""/> This statement must be included when an implicit intent is required to be passed to an object. For example, android: scheme = "tell" android: mimeType = "" indicates the type of the input parameter
Application scenarios
  • Explicit: Start the Activity in the same application
  • Implicit intent: Start Activity in different applications
  • The restart efficiency is far lower than the explicit
  • If there are multiple activities in the system that match the Action set with the intent, a dialog box will pop up when the Activity is started, containing all the matching activities.
Activity Task Stack
  • When an application is running, multiple activities may be opened in the memory, so all opened activities will be saved in the Activity Task Stack.
  • STACK: The last stack is the first stack.
Activity Startup Mode
  • Standard mode: the default mode is advanced and later
  • SingleTop: if the target Activity is not at the top of the stack, a new Activity will be started. If the Activity is already at the top of the stack, it will not be started again.
  • SingleTask: If no Activity exists in the stack, an Activity is created at startup. If an instance of the Activity already exists in the stack, all the activities above the Activity in the stack are killed, and the Activity becomes the Activity at the top of the stack.
    • SingleTask: Ensure that there is only one instance of the Activity in the entire stack.
  • SingleInstance: An Activity in this mode has its own independent task stack. Only one instance of this Activity is created and saved in an independent task stack.
    • SingleInstance: Ensure that there is only one instance of the Activity in the memory of the whole system.

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.