当前位置: 移动技术网 > IT编程>网页制作>Html5 > HTML5打开本地app应用的方法

HTML5打开本地app应用的方法

2019年07月25日  | 移动技术网IT编程  | 我要评论

还剑奇情录txt下载,王丽娟护士长,旱冰鞋教程视频

本文为大家分享了html5打开本地app应用的方法,具体内容如下

首先为了保证能够打开你的app,你必须要在androidmanifest.xml中配置的filter中data的属性表述。<data android:pathprefix="/taoge/open" android:scheme="xttblog"></data> androidmanifest.xml代码如下:

xml/html code复制内容到剪贴板
  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>  

其次,你要在你的网页中访问xttblog://taoge/open。可以使用的元素有很多,如:script,iframe,img等。使用它们的src属性,访问xttblog://taoge/open。html5代码如下:

xml/html code复制内容到剪贴板
  1. <!doctype html>  
  2. <html>  
  3. <script>  
  4.  function openapp(){   
  5.   document.getelementbyid('xttblog').innerhtml='<iframe src="xttblog://taoge/open"></iframe>';   
  6.  }   
  7. </script>  
  8. <body>  
  9.  <div style="display:none;" id="xttblog"></div>  
  10.  <input type="button" value="打开app" onclick="openapp();">  
  11. </body>  
  12. </html>  

以上就是本文的全部内容,希望对大家的学习有所帮助。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网