HTML5打開本地app應(yīng)用的方法
發(fā)布時間:2016-03-31 11:28:02 作者:佚名
我要評論

這篇文章主要介紹了HTML5打開本地app應(yīng)用的方法,如果你的手機上安裝有支付寶,那么在訪問支付寶手機網(wǎng)頁時就會自動打開支付寶app,否則在頁面上會提示你進行下載app,這是如何實現(xiàn)的?感興趣的小伙伴們可以參考本文
本文為大家分享了HTML5打開本地app應(yīng)用的方法,具體內(nèi)容如下
首先為了保證能夠打開你的app,你必須要在androidManifest.xml中配置的filter中data的屬性表述。<data android:pathprefix="/taoge/open" android:scheme="xttblog"></data> androidManifest.xml代碼如下:
XML/HTML Code復制內(nèi)容到剪貼板
- <?xml version="1.0" encoding="utf-8"?>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.taoge"
- android:versionCode="2"
- android:versionName="3.24.03" >
- <uses-sdk
- android:minSdkVersion="8"
- android:targetSdkVersion="17" />
- <application
- android:allowBackup="true"
- android:configChanges="orientation|screenSize"
- android:icon="@drawable/logo"
- android:label="@string/app_name"
- android:logo="@drawable/logo"
- android:sharedUserId="android.uid.system"
- android:theme="@android:style/Theme.Light.NoTitleBar" >
- <activity
- android:name="xttblog.WelcomeActivity"
- android:excludeFromRecents="true"
- android:screenOrientation="portrait"
- android:theme="@android:style/Theme.Light.NoTitleBar" >
- <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.BROWSABLE" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:pathPrefix="/taoge/open"
- android:scheme="xttblog" />
- </intent-filter>
- </activity>
- <activity
- android:name="xttblog.AntRepairActivity"
- android:label="@string/title_activity_ant_repair" >
- </activity>
- </application>
- </manifest>
其次,你要在你的網(wǎng)頁中訪問xttblog://taoge/open??梢允褂玫脑赜泻芏?,如:script,iframe,img等。使用它們的src屬性,訪問xttblog://taoge/open。html5代碼如下:
XML/HTML Code復制內(nèi)容到剪貼板
- <!DOCTYPE HTML>
- <html>
- <script>
- function openapp(){
- document.getElementById('xttblog').innerHTML='<iframe src="xttblog://taoge/open"></iframe>';
- }
- </script>
- <body>
- <div style="display:none;" id="xttblog"></div>
- <input type="button" value="打開app" onclick="openapp();">
- </body>
- </html>
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助。
相關(guān)文章
淺談html5與APP混合開發(fā)遇到的問題總結(jié)
這篇文章主要介紹了淺談html5與APP混合開發(fā)遇到的問題總結(jié)的相關(guān)資料,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-03-20- 這篇文章主要介紹了Html5 APP中監(jiān)聽返回事件處理的方法示例的相關(guān)資料,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-03-15
使用html5新特性輕松監(jiān)聽任何App自帶返回鍵的示例
這篇文章主要介紹了使用html5新特性輕松監(jiān)聽任何App自帶返回鍵的示例的相關(guān)資料,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-03-13- 這篇文章主要介紹了HTML5頁面中嘗試調(diào)起APP功能,需要的朋友可以參考下2017-09-12
HTML5 Plus 實現(xiàn)手機APP拍照或相冊選擇圖片上傳功能
這篇文章主要為大家詳細介紹了HTML5 Plus的Camera、GalleryIO、Storage和Uploader,實現(xiàn)手機APP拍照或相冊選擇圖片上傳功能的相關(guān)資料,感興趣的小伙伴們可以參考一下2016-07-13html5調(diào)用app分享功能示例(WebViewJavascriptBridge)
這篇文章主要介紹了html5調(diào)用app分享功能示例(WebViewJavascriptBridge)的相關(guān)資料,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-03-21