本文为大伙儿共享了HTML5开启当地app运用的方式,实际內容以下
最先以便确保可以开启你的app,你务必要在androidManifest.xml中配备的filter中data的特性描述。<data android:pathprefix="/taoge/open" android:scheme="xttblog"></data> androidManifest.xml编码以下:
XML/HTML Code拷贝內容到剪贴板
- <?xml version="1.0" encoding="utf⑻"?>
- <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>
其次,你要在你的网页页面中浏览xttblog://taoge/open。可使用的元素有许多,如:script,iframe,img等。应用它们的src特性,浏览xttblog://taoge/open。html5编码以下:
XML/HTML Code拷贝內容到剪贴板
- <!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>
以上便是本文的所有內容,期待对大伙儿的学习培训有一定的协助。