Android intent learning Summary

Source: Internet
Author: User

Basic Mode:

1. In firstactivity:

Intent intent = new intnet ();

Intent. setclass (firstactivity. This, secondactivity. Class );

Startactivity (intent );

2. add permissions to androidmanifest. xml.

</Activity Android: Name = "secondactivity"

Android: Label = "text"

</Activity>

3. secondactivity

Intent intent = getintent ();

To get what you need.

4. Flags attribute of intent

I. Relationship between activity and task (stack)
Task is like a container, and activity is equivalent to filling in the container. The first thing (activity) will be at the bottom, and the last added thing (activity) it will be at the lowest end. Retrieving an activity from a task is extracted from the top, that is, the last added activity is retrieved first, and so on, the last activity is added for the first time, and the sequence of the activity in the task is
Can be controlled, so intent flag is used for activity jump.
2. Intent is used for page Jump and service start. Intent flag is about activity jump.
Intent intent = new intent (this, XXX. Class );
// If the activity exists in the task, it gets to the top and does not start a new activity.
Intent. addflags (intent. flag_activity_brought_to_front );
// If the activity exists in the task, terminate all the activities on the activity.
Intent. addflags (intent. flag_activity_clear_top );
// The default redirect type. Place the activity in a new task.
Intent. addflags (intent. flag_activity_new_task );
// If the activity has been run to a task, the activity will not be running again
Intent. addflags (intent. flag_activity_single_top );

Related Article

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.