Android Program Development: (2) use intent-2.2 to resolve intent-filter conflicts

Source: Internet
Author: User
We already know that <intent-filter> is used to define how your activity is enabled by another activity. This is the so-called "filter ". However, if two activities have the same <intent-filter>, what will happen?

In androidmanifest. XMLCode.

[Java] View plaincopy
  1. <? XML version ="1.0"Encoding ="UTF-8"?>
  2. <Manifest xmlns: Android =Http://schemas.android.com/apk/res/android"
  3. Package="Net. horsttnann. usingintent"
  4. Android: versioncode ="1"
  5. Android: versionname ="1.0">
  6. <Uses-SDK Android: minsdkversion ="14"/>
  7. <Application
  8. Android: icon ="@ Drawable/ic_launcher"
  9. Android: Label ="@ String/app_name">
  10. <Activity
  11. Android: Label ="@ String/app_name"
  12. Android: Name =". Usingintentactivity">
  13. <Intent-filter>
  14. <Action Android: Name ="Android. Intent. Action. Main"/>
  15. <Category Android: Name ="Android. Intent. Category. launcher"/>
  16. </Intent-filter>
  17. </Activity>
  18. <Activity
  19. Android: Label ="Second Activity"
  20. Android: Name =". Secondactivity">
  21. <Intent-filter>
  22. <Action Android: Name ="Net. horsttnann. secondactivity"/>
  23. <Category Android: Name ="Android. Intent. Category. Default"/>
  24. </Intent-filter>
  25. </Activity>
  26. <Activity
  27. Android: Label ="Third activity"
  28. Android: Name =". Thirdactivity">
  29. <Intent-filter>
  30. <Action Android: Name ="Net. horsttnann. secondactivity"/>
  31. <Category Android: Name ="Android. Intent. Category. Default"/>
  32. </Intent-filter>
  33. </Activity>
  34. </Application>
  35. </Manifest>

If you use startactivity () to start the activity, the android system will pop up a window for selecting the activity.

Analysis:

To clear the "default activity" information, go to settings-> Applications-> Manage applications page, select the application usingintent, slide the view to the bottom, and click the CEAR ults button.

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.