欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

HTML5打开本地app应用的方法_html5教程技巧

程序员文章站 2022-04-29 11:45:47
...
本文为大家分享了HTML5打开本地app应用的方法,具体内容如下

首先为了保证能够打开你的app,你必须要在androidManifest.xml中配置的filter中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. /span>>
  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="打开app" onclick="openapp();">
  11. body>
  12. html>

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