[英]Open Android app via scheme without using url
I have an android scheme name: android.scheme and I want to open the android app when i click on: 我有一个android方案名称:android.scheme,我想在单击时打开android应用程序:
android.scheme://serversettings?personalizationhost=192.168.32.122&personalizationport=8080&vpnhost=192.168.32.122
How I can do that any help? 我该怎么做呢?
I know how I can achieve the same using but putting this in an HTML page and opening that page will open the app like this: 我知道如何使用来实现相同的目的,但是将其放在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>
But I don't want to click on url and then open the app. 但我不想单击url,然后打开应用程序。 I want to click on android.scheme directly which opens the app.
我想直接点击android.scheme,打开应用程序。 Any help will be appreciated?
任何帮助将不胜感激?
You don't need to create a separate page that redirects to the URI with android.scheme scheme. 您无需创建单独的页面即可使用android.scheme方案重定向到URI。 You can create a link on the original page using the same scheme.
您可以使用相同的方案在原始页面上创建链接。 Something like:
就像是:
<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>
And add an intent filter for the launched intent to your Activity: 并为活动添加针对启动的意图的意图过滤器:
<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>
You can even use the same scheme to launch different activities by using differents hosts for the data filter and corresponding URL: 您甚至可以通过使用不同的主机作为数据过滤器和相应的URL,使用相同的方案来启动不同的活动:
<data android:scheme="android.scheme" android:host="serversettings" />
or 要么
<data android:scheme="android.scheme" android:host="clientstatus" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.