Android uses intent to link activity and intent filters

Source: Internet
Author: User

In Android, an activity represents an interface that uses intent to link different activities

Create a new project,

Create a new class class that is named New1activity.

Add a key to the XML

Add the following code in the Mainactivity.java

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/59/BD/wKiom1TdmzihzfvGAAD_8DcUU_c564.jpg "title=" 2.png " alt= "Wkiom1tdmzihzfvgaad_8dcuu_c564.jpg"/>

In Androidmanifest.xml, add the following code 650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M02/59/BA/wKioL1TdmWjBO_ V8aahnlitqf5o593.jpg "title=" 1.png "alt=" Wkiol1tdmwjbo_v8aahnlitqf5o593.jpg "/>

Run the results, click

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/59/BA/wKioL1TdnOnAAkbwAACQzQ-Jqbg301.jpg "style=" float: none; "title=" 3.png "alt=" Wkiol1tdnonaakbwaacqzq-jqbg301.jpg "/>

Click the OK button to jump to another interface

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/59/BD/wKiom1Tdm_GwfvlLAACjYI226y0685.jpg "style=" float: none; "title=" 4.png "alt=" Wkiom1tdm_gwfvllaacjyi226y0685.jpg "/>


Resolve Intent Filter conflicts

Then create a new class, named New2activity, repeat the above steps, add code in Androidmanifest.xml, 650) this.width=650; "Src=" http://s3.51cto.com/ Wyfs02/m01/59/ba/wkiol1tdne3jb4phaaishqiarke431.jpg "title=" 1.png "alt=" Wkiol1tdne3jb4phaaishqiarke431.jpg "/>

Note that the names of New1 and New2 are different, but the intention is to have the same name in the selector,

In Mainactivity. Modify the code in Java to modify the intent to the name 650 in. xml) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M01/59/BD/ Wkiom1tdnxhtr2ttaaetcur-m1c709.jpg "title=" 2.png "alt=" Wkiom1tdnxhtr2ttaaetcur-m1c709.jpg "/>


Ps:intent parameters, directly using the class name, as above, can only invoke the activity of this project, using the intent of the selector alias, you can invoke any (can not this project) activity.

This article is from the "Useless Uncle" blog, please be sure to keep this source http://aslonely.blog.51cto.com/6552465/1614296

Android uses intent to link activity and intent filters

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.