qq. the page shared by WeChat. How to call up an app and call it to a specific page
The URL Scheme is supported by iOS and Android platform. Only the scheme needs to be registered when the native APP is developed. When the user clicks the link, the APP will wake up automatically. With the help of the URL Router mechanism, the user can also jump to the specified page.
Steps:
(1) h5 page jump page format is written like this. For example, the jump page format is app://abc. If you need to transfer parameters, add (?) after it? Key = value)
- <a class="btn_hy" id="openApp">I want to share</a>
- <script type="text/javascript">
- document.getElementById('openApp').onclick = function(){
- window.location.href = "app://abc";
- window.setTimeout(function(){
- window.location.href = "
- http://xxx/mobile/xxxx.apk "; / / open the app download address provided by the app colleague
- },2000)
- };
- </script>
(2) android side. It needs to be in android manifest.xml. Add an intent filter to the activity of the specified page that needs to be opened
The code is as follows:
- <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:host="abc"
- android:scheme="app" >
- </data>
- </intent-filter>
Complete example:
- <activity
- android:name="com.example.app.ui.WebViewActivity"
- android:label="@string/app_name"
- android:screenOrientation="portrait"
- android:windowSoftInputMode="stateHidden|adjustPan" >
- <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:host="abc"
- android:scheme="app" >
- </data>
- </intent-filter>
- </activity>
app://abc
Here, sheme is the jump address written in h5 above, corresponding to app
The host here is the jump address written in h5 above, corresponding to abc
Be careful not to write wrong here.
Reprinted from: https://blog.csdn.net/bangyingqing/article/details/70174519