我有一个android方案名称:android.scheme,我想在点击时打开Android应用程序:
android.scheme://serversettings?personalizationhost=192.168.32.122&personalizationport=8080&vpnhost=192.168.32.122
我怎么能帮到你呢?
我知道如何实现相同的使用,但将其放入HTML页面并打开该页面将打开这样的应用程序:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<script type="text/javascript">
window.location.href = "android.scheme://serversettings?personalizationhost=192.168.32.122&personalizationport=8080&vpnhost=192.168.32.122"</script>
<title>AuthenticVPN Settings</title>
</head>
<body>
</body>
</html>
但我不想点击网址,然后打开应用。我想直接点击android.scheme打开应用程序。 任何帮助将不胜感激?
答案 0 :(得分:0)
您无需使用android.scheme方案创建一个重定向到URI的单独页面。您可以使用相同的方案在原始页面上创建链接。类似的东西:
<html>
<head>
</head>
<body>
You can <a href="android.scheme://serversettings?personalizationhost=192.168.32.122&personalizationport=8080&vpnhost=192.168.32.122">launch Activity</a> directly with anchor tags.
</body>
</html>
为您的活动添加已启动意图的意图过滤器:
<intent-filter>
<data android:scheme="android.scheme"/>
<data android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
您甚至可以使用相同的方案通过使用数据过滤器的不同主机和相应的URL来启动不同的活动:
<data android:scheme="android.scheme" android:host="serversettings" />
或
<data android:scheme="android.scheme" android:host="clientstatus" />