Android 如何通过html打开本地App?
HTML代码:
方法一:iframe实现跳转
var appUrl = 'market://';
var ifr = document.createElement('iframe');
var body = document.body;
ifr.style.cssText='display:none;width=0;height=0';
ifr.setAttribute('src', appUrl)
body.appendChild(ifr);
方法二:href实现跳转
var appUrl = 'market://';
window.location.href = appUrl
Android代码:
在manimanifest设置:
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="market"/>
</intent-filter>
注意事项:
scheme的名称支持自定义,但是必须都是小写字母;