For android, click the short link to enter the application and obtain the entire connection content.

Source: Internet
Author: User

For example: I receive a text message is a link: http://www.qq.com/a/ B ?, When I click here, I want to achieve the following scenario: Click -----. There are two options: this application is available on the mobile phone and jump to the application; otherwise, the page is displayed.

I won't talk about jumping into the web page. This will jump over without writing anything. It is an http hyperlink. The following describes how to let the system find my application based on the written connection, and obtain the complete address in the program:

1. First, add the following code to the activity you want to jump to in manifest. xml:


<Intent-filter>
<Action android: name = "android. intent. action. VIEW"/>

<Category android: name = "android. intent. category. DEFAULT"/>
<Category android: name = "android. intent. category. BROWSABLE"/>

<Data android: pathPrefix = "/a" android: host = "www.qq.com" android: scheme = "http"/>
</Intent-filter>

 
 

Note: In the above Code, android: pathPrefix = "/a" defines the initial part of the URI of the Data subset of the content provider. This indicates setting schema (http) all supported link Headers

When the host (subject part of our link) is the same as the short link, there is also a filter attribute: pathPrefix, the value of this attribute only needs to fill in the first "/*" content after the link subject. Of course, there is also an attribute that provides the complete URI: android: pathpattern, the two attributes depend on whether the URI is fixed. In my example, the link tail is not fixed, so I use android: the pathPrefix attribute will fill in the fixed filtering content on the line, when the http://www.qq.com/a/ B? As long as the connection remains unchanged at http://www.qq.com/a, the option of this application will pop up in the future.

The following figure shows how to extract the entire connection content in my code after I click "Connect" and click "my application:

Try {
Log. e ("Get all the content of the clicked connection", getIntent ()
. GetDataString ());
} Catch (Exception e ){
// TODO Auto-generated catch block
Log. e ("e. printStackTrace ()", "Wipe, brother is not coming in from the short link! ");
}


 


}

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.