Concept and application of intent in Android (ii)--intent filter related options

Source: Internet
Author: User

If multiple activity has the same intent action, what happens when starting with the same action? How do I specify an activity to start?

In cases where multiple activity has the same intent action, if you want to start a specified activity, the <intent-filter>

Add <data android:scheme= "app"/>. Also, write the code that starts as:

StartActivity (New Intent ("Com.w.learnintent.intent.action.myaty", Uri.parse ("app://myaty1"));

second, how to initiate local activity via a browser link?

1. Create a new activity in the new project Launchlocalapp and configure it in the Androidmanifest.xml file:

<activity android:name= ". Localappaty ">
<intent-filter>
<category android:name= "Android.intent.category.BROWSABLE"/> <!--available--
<category android:name= "Android.intent.category.DEFAULT"/>
<action android:name= "Android.intent.action.VIEW"/>
<data android:scheme= "App"/> <!--agreement name--
</intent-filter>
</activity>

install it on the emulator.

2. Write the index.html page (webstorm) and execute:

<a href= "App://localapp" >launch My app</a> <!--Localapp is any parameter--

3. Access the 10.0.2.2:63343/webstormprojects/index.html through the browser in the simulator, click the link to access the activity

(localhost is accessed via the simulator and its address is 10.0.2.2).

Additional

When using Webstorm, pop-up requested without authorization,you can copy URL and open it in browser to trust it issues.

Solution:

File->settings->build,execution,deployment->debugger, select the option on the Allow unsigned requests, and apply it. )

Third, how can I receive the parameters passed over?

Localappaty.java:

    Uri uri = getintent (). GetData ();
System.out.println (URI);

  Run the program with console output:

I/system.out:app://localapp

Concept and application of intent in Android (ii)--intent filter related options

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.