接著上一篇 LINE 貼圖網址傳回的資料分析 ,接下來要在 Android 的 WebView 裡開啟我們的App 或讓使用著去 Google Play Store 下載 App.
資料來源:Android Intents with Chrome
https://developer.chrome.com/multidevice/android/intents
LINE 的使用範例:
- 開啟貼圖小舖:
intent://shop/detail/8072#Intent;scheme=line;action=android.intent.action.VIEW;category=android.intent.category.BROWSABLE;package=jp.naver.line.android;end - 開啟Play商店:
market://details?id=jp.naver.line.android
Google 官方的使用範例:
Here’s an intent that launches the Zxing barcode scanner app. It follows the syntax thus:
intent:
//scan/
#Intent;
package=com.google.zxing.client.android;
scheme=zxing;
end;
To launch the Zxing barcode scanner app, you encode your href
on the anchor as follows:
<a href="intent://scan/#Intent;scheme=zxing;package=com.google.zxing.client.android;end"> Take a QR code </a>
See the Android Zxing Manifest, which defines the package and the host.
Also, if fallback URL is specified, the full URL will look like this:
<a href="intent://scan/#Intent;scheme=zxing;package=com.google.zxing.client.android;S.browser_fallback_url=http%3A%2F%2Fzxing.org;end"> Take a QR code </a>
Now the URL will get you to zxing.org if the app could not be found, or the link was triggered from JavaScript without user gesture (or for other cases where we don’t launch an external application.)
附註:如果你用的是 Cordova 請參考這一篇:
https://stackoverflow.max-everyday.com/2017/11/opening-links-from-cordova-app-in-external-app-facebook-twitter-or-browser-both-for-ios-and-android-ask-question/