Some websites have set a link on the page to jump to their official app, such as JD. Recently, I added this feature to Wang Baiyuan’s blog client to open links on web pages and call my client to open related articles. .The following is the implementation method:
Android implementation opens a specified link to call other applications
Add an intent-filter tag in the AndroidManifest.xml manifest file of the Activity that needs to jump to the specified link, and set the scheme, HOST, and other attributes as shown in the following example.
1 2 3 4 5 6 7 8 9 10 11 |
<intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <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="wbyblog" android:host="wangbaiyuan.cn" Android:pathPrefix="/home"/> </intent-filter> |
And made a web page test successfully:
1 2 3 |
<a href="wbyblog://wangbaiyuan.cn/home">Open the home page</a><!-- This is the call to mainActivity above --> <a href="wbyblog://wangbaiyuan.cn/post?postid=1024&title=How Android Enables Browsers to Call Other Applications">Open Article</a> <a href="wbyblog://wangbaiyuan.cn/category?id=10">Open the Directory</a> |
This article has been printed on copyright and is protected by copyright laws. It must not be reproduced without permission.If you need to reprint, please contact the author or visit the copyright to obtain the authorization. If you feel that this article is useful to you, you can click the "Sponsoring Author" below to call the author!
Reprinted Note Source: Baiyuan's Blog>>https://wangbaiyuan.cn/en/android-open-specified-link-call-other-app-2.html
No Comment