Home  >  Article  >  Web Front-end  >  How to open a local app in HTML5_html5 tutorial tips

How to open a local app in HTML5_html5 tutorial tips

WBOY
WBOYOriginal
2016-05-16 15:51:511431browse

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
  1. xml version="1.0" encoding="utf-8"?>  
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     package="com.taoge"  
  4.     android:versionCode="2"  
  5.     android:versionName="3.24.03" >  
  6.     <uses-sdk  
  7.         android:minSdkVersion="8"  
  8.         android:targetSdkVersion="17" />  
  9.     <application  
  10.         android:allowBackup="true"  
  11.         android:configChanges="orientation|screenSize"  
  12.         android:icon="@drawable/logo"  
  13.         android:label="@string/app_name"  
  14.         android:logo="@drawable/logo"  
  15.         android:sharedUserId="android.uid.system"  
  16.         android:theme="@android:style/Theme.Light.NoTitleBar" >  
  17.         <activity  
  18.             android:name="xttblog.WelcomeActivity"  
  19.             android:excludeFromRecents="true"  
  20.             android:screenOrientation="portrait"  
  21.             android:theme="@android:style/Theme.Light.NoTitleBar" >  
  22.             <intent-filter>  
  23.                 <action android:name="android.intent.action.MAIN" />  
  24.                 <category android:name="android.intent.category.LAUNCHER" />  
  25.             intent-filter>  
  26.             <intent-filter>  
  27.                 <action android:name="android.intent.action.VIEW" />  
  28.                 <category android:name="android.intent.category.BROWSABLE" />  
  29.                 <category android:name="android.intent.category.DEFAULT" />  
  30.                 <data android:pathPrefix="/taoge/open"  
  31.                     android:scheme="xttblog" />  
  32.             intent-filter>  
  33.         activity>  
  34.         <activity  
  35.             android:name="xttblog.AntRepairActivity"  
  36.  android:label="@string/title_activity_ant_repair" >
  37. activity>
  38. application>
  39. 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
  1. >
  2. <html>
  3. <script>
  4. function openapp(){
  5. document.getElementById('xttblog').innerHTML='';
  6. }
  7. script>
  8. <body>
  9. <div style="display: none;" id="xttblog">div>
  10. <input type="button" value="Open app" onclick= "openapp();">
  11. body>
  12. html>

The above is the entire content of this article, I hope it will be helpful to everyone’s study.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn