This article shares with you how to open a local app using HTML5. The specific content is as follows
First of all, in order to ensure that your app can be opened, you must express the data attribute in the filter configured in androidManifest.xml. androidManifest.xml code is as follows:
XML/HTML CodeCopy content to clipboard
-
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>
Secondly, you need to visit xttblog://taoge/open in your web page. There are many elements that can be used, such as: script, iframe, img, etc. Using their src attribute, visit xttblog://taoge/open. The html5 code is as follows:
XML/HTML CodeCopy content to clipboard
-
>
-
<html>
-
<script>
-
function openapp(){
-
document.getElementById('xttblog').innerHTML='';
-
}
-
script>
-
<body>
-
<div style="display: none;" id="xttblog">div>
-
<input type="button" value="Open app" onclick= "openapp();">
-
body>
-
html>
The above is the entire content of this article, I hope it will be helpful to everyone’s study.