html5åé¾æ¥æå¼iosåandroidæ¬å°åºç¨
16lz
2021-01-23
1ãå¨htmlä¸è®¾ç½®é¾æ¥
href=”[scheme]://[host]/[path]?[query]”
schemeå¯ä»¥èªå·±å¨appå é¨è®¾ç½®æä»»æçï¼æandroidåiosç设置æä¸æ·ç
2ãè¥æ¬å°åºç¨åå¨ï¼ç´æ¥æå¼appï¼è¥ä¸åå¨ï¼è®¡æ¶ä¸æ®µæ¶é´è·³å°appstore
éè¦å¤æiosè¿æ¯androidå¹³å°ä¸çæµè§å¨ï¼éè¦å¤æ微信æµè§å¨
<code class="hljs" javascript="">var openApp = function () { var btnOpenApp = document.getElementById(open-app); btnOpenApp.onclick = function () { //æå¼æ¬å°åºç¨å½æ° var open=function(url){ var timeout; function try_to_open_app() { timeout = setTimeout(function(){ window.location.href=url; console.log(22) }, 10); } try_to_open_app(); } if (/android/i.test(navigator.userAgent)) { //alert(This is Android'browser.);//è¿æ¯Androidå¹³å°ä¸æµè§å¨ if (/MicroMessenger/i.test(navigator.userAgent)) { alert(This is MicroMessenger browser,请使ç¨æ¬å°æµè§å¨æå¼);//è¿æ¯å¾®ä¿¡å¹³å°ä¸æµè§å¨ } else { open(andoridåºç¨å¸åºurl); } } if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) { //alert(This is iOS'browser.);//è¿æ¯iOSå¹³å°ä¸æµè§å¨ if (/MicroMessenger/i.test(navigator.userAgent)) { alert(微信å ç½®æµè§å¨ä¸æ¯ææå¼æ¬å°åºç¨,请ç¹å»å³ä¸è§ä½¿ç¨æ¬å°æµè§å¨æå¼);//è¿æ¯å¾®ä¿¡å¹³å°ä¸æµè§å¨ } else { open(iosåºç¨å¸åºurl); } } };}</code>
ããAndroidé ç½®
<activity android:name=".ui.UploadActivity" android:screenOrientation="portrait"> <intent-filter> <data android:scheme="http" android:host="192.168.167.33" android:port="8088" android:path="/mi-tracker-web/download.html"/> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> </intent-filter> </activity>
<a id="applink1" href="http://192.168.167.33:8088/mi-tracker-web/download.html"> Open Application</a>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Insert title here</title></head><body> <script type="text/javascript"><span style="white-space:pre"> </span>window.location="market://search?q=com.singtel.travelbuddy.android";</script>
String str = "market://details?id=" + getPackageName(); Intent localIntent = new Intent("android.intent.action.VIEW"); localIntent.setData(Uri.parse(str)); startActivity(localIntent);
HTMLé 置示ä¾
<a href="myapp://com.myapp/?params1=123¶ms2=EFDAFDA">Open app</a><br/>
<a href="market://search?q=æçapp">Open Market</a><br/>
<a href="market://details?id=com.myapp">Open Market Details</a><br/>
<script type="text/javascript">
window.location.href="myapp://com.myapp/?params1=123¶ms2=EFDAFDA";
</script>
Androidè·ååæ°ï¼
Uri uri = getIntent().getData(); String test1= uri.getQueryParameter("arg0"); String test2= uri.getQueryParameter("arg1");
webView.setWebViewClient(new WebViewClient(){ @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { Uri uri=Uri.parse(url); if(uri.getScheme().equals("m")&&uri.getHost().equals("my.com")){ String arg0=uri.getQueryParameter("arg0"); String arg1=uri.getQueryParameter("arg1"); }else{ view.loadUrl(url); } return true; }});
更多相关文章
- 代码中设置drawableleft
- android 3.0 隐藏 系统标题栏
- Android开发中activity切换动画的实现
- Android(安卓)学习 笔记_05. 文件下载
- Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
- 技术博客汇总
- android 2.3 wifi (一)
- AndRoid Notification的清空和修改
- Android中的Chronometer