The first step is to say the principle of implementation:
Use steps
First, the Activity settings filter in the app you want to open (set in the manifest file)
Taking Jumpactivity as an example
As in the following: <intent-filter> is the desired filter
<activity android:name= ". Jumpactivity "> <intent-filter> <action android:name=" Android.intent.action.VIEW "/> <category android:name= "Android.intent.category.DEFAULT"/> <category android:name= " Android.intent.category.BROWSABLE "/> <!--the required and HTML-side swap--><!--set the scheme and host in data The activity can receive and process links like "sharetest://data/xxx"-- <data android:host= "Data" android:scheme= " Sharetest "/> </intent-filter>
Second, in the jumpactivity to do open processing, to receive the external jump
public class Jumpactivity extends activity{ @Override protected void onCreate (Bundle savedinstancestate) { //TODO auto-generated method Stub super.oncreate (Savedinstancestate); Intent Intent = Getintent ();//In this activity, we can use the getintent () to get the information from the external jump. String data = intent.getdatastring ();//received a Web page that came from: sharetest://data/http://www.huxiu.com/ string[] split = Data.split ("data/");//To data/cut the data string URL = split[1];//To get: http://www.huxiu.com/( This is the data we need to send to our website) ... Then we can open the app via the Web page and use the URL data we get to do something we need to do, like when you open your Android app while you're browsing the web, and load an app page}.
Third, we need to find the HTML front-end to let them join in the page:
<iframe src= "" style= "Display:none" ></iframe>
as follows: index.html
<! DOCTYPE html>
Put index.html in the assets directory, call WebView in the code to load the HTML file, the code is as follows:
/* Page Open app*/
public class H5toappactivity extends Activity { private String URL; Private WebView WebView; @Override protected void onCreate (Bundle savedinstancestate) { super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_h5_app); WebView = (webview) Findviewbyid (R.ID.WEBVIEWH5); url = "file:///android_asset/index.html"; WebSettings WSet = Webview.getsettings (); Wset.setjavascriptenabled (true); Webview.loadurl (URL);} }
This allows you to open the corresponding app when you execute the above code.
For example, my 2048 is a Web page, when you open the Web page can open another applicationHere are two apps you can download below to see the effect: (two apps together)
2048 Web Demo apk:http://download.csdn.net/detail/qiushi_1990/9514778
Web page Open App apk:http://download.csdn.net/detail/qiushi_1990/9514779
This will show the following effect when you open 2048
Then it jumps to the following application
Implementation principle
Recently, in the use of QQ and other SDK to achieve the sharing of Web pages, it was found that the SDK has been for the page jump back to the application provides basic data support. We can do this simply by simply setting it in the app and the shared page.
So let's take a look at the implementation principle of the Web page jump back to the application.
For Android, the URI is divided into three parts: scheme, authority and path. Among them, authority is divided into host and port. The format is as follows:
Scheme://host:port/path
To give a practical example:
Content://com.example.project:200/folder/subfolder/etc
\---------/ \---------------------------/ \---/ \--------------------------/
Scheme Host Port Path
\--------------------------------/
Authority
Now you should know what those attributes in data flag mean, look at the data flag.
<data android:host= "string"
Android:mimetype= "string"
Android:path= "string"
Android:pathpattern= "string"
android:pathprefix= "string"
Android:port= "string"
Android:scheme= "string"/>
Click and QQ share jump to the inside of the program principle is consistent with this.
Android jump to App from Web page