How does Android jump into the App from the outside and Android jump into the App?

Source: Internet
Author: User

How does Android jump into the App from the outside and Android jump into the App?

Solving this problem has two functions:

1. directly access a page without opening the App

2. share an App to the outside, and access the closed loop of the App from the outside.

This topic can be divided into two aspects, one is from accessing the App, and the other is from the web page to the App.

Let's talk about it at http://my.oschina.net/liucundong/blog/354029.

Data Information such as scheme, host, path, and pathPrefix is used to differentiate

Both solutions need to add intent-filter information to the Activity to jump to, for example

<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: scheme = "cundong" android: host = "splash"/>

</Intent-filter>

First, let's go to the App. The scenario is from sharing the content of the App to directly opening the App.

Step 1: complete the registration of public platforms, related enterprise information, download links, and logos.

Step 2: Use WXAppExtendObject during sharing and assign the url to extInfo

Step 3: Initiate your jump when req. getType () = ConstantsAPI. COMMAND_SHOWMESSAGE_FROM_WX of the onReq method of the IWXAPIEventHandler Interface

Step 4: data is required during the jump, where the data comes from, and from the getIntent object of the onCreate method in the WXEntryActivity class

The process ends from entering the App.

------------------- I am a split line ------------------------

Next, because webView restrictions such as Weibo and Weibo all use this control on the web page, you can only share the content on the web page and then access the App.

The principle is as follows:

<Div>
<A id = "J-call-app" href = "javascript:;" class = "label"> open now & gt; </a>
<Input id = "J-download-app" type = "hidden" name = "storeurl" value = "http://apk.hiapk.com/appinfo/com.tmall.wireless">
</Div>
 
<Script>
(Function (){
Var ua = navigator. userAgent. toLowerCase ();

Var t;
Var url = document. location;
Var config = {
/* Scheme: required */
Scheme_IOS: 'cundong ://',
Scheme_Adr: 'cundong: // splash ',
Download_url: document. getElementById ('J-download-app'). value,
Timeout: 600
};
 
Function openclient (){
Var startTime = Date. now ();
 
Var ifr = document. createElement ('iframe ');
 
// Alert (config. scheme_Adr );
Ifr. src = ua. indexOf ('OS')> 0? Config. scheme_IOS: config. scheme_Adr;
Ifr. style. display = 'none ';
Document. body. appendChild (ifr );
 
Var t = setTimeout (function (){
Var endTime = Date. now ();
 
If (! StartTime | endTime-startTime <config. timeout-200 ){
Window. location = config. download_url;
} Else {
Window. location. href = ifr. src. replace ("http: //", "cundong ://");;
}
}, Config. timeout );


 
Window. onblur = function (){
ClearTimeout (t );
}
}
Window. addEventListener ("DOMContentLoaded", function (){
Document. getElementById ("J-call-app"). addEventListener ('click', openclient, false );
 
}, False );
})()
</Script>

Click "open" and execute a javascript code. If the App can be opened within the specified time, it will be opened; otherwise, the download page will be displayed.

This is the basic idea for solving this problem. You are welcome to discuss it!

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.