我正在开发一款应用,我需要在需要时打开网址方案。我的意思是:
我们有两个手机,即发送者和接收者。接收方正在等待发送方发送url方案的变量。当接收者获得该变量时,它将其添加到url方案,然后尝试打开(重定向)到另一个本机应用程序(url方案)。
它在Android中默认安装的原生互联网浏览器中运行良好,但有些手机只有谷歌浏览器。
所以主要的问题是我无法在Android中使用谷歌浏览器(从其他手机或超时)打开网址方案。
我试过的其中一个代码:
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
window.onload = function() {
setTimeout(function() {
window.location = "twitter://";
}, 500);
};
</script>
<iframe id="l" width="1" height="1" style="visibility:hidden"></iframe>
</body>
</html>
提前致谢并希望找到解决方案!
答案 0 :(得分:0)
其他方法可以使用Android Intents:
<a href="intent://scan/#Intent;scheme=zxing;package=com.google.zxing.client.android;end"> Take a QR code </a>
然后像这样设置清单
<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="zxing" android:host="scan" android:path="/"/>
</intent-filter>