[英]Open Android app via scheme without using url
我有一個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>
但我不想單擊url,然后打開應用程序。 我想直接點擊android.scheme,打開應用程序。 任何幫助將不勝感激?
您無需創建單獨的頁面即可使用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" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.