我爲我們的網站製作了一個android webview應用程序。現在我想添加深層鏈接到應用程序,就像有人點擊我們網站的鏈接時,您可以使用webview應用程序而不是Chrome瀏覽器打開它。我說這些我的清單:深入鏈接webview內的右側頁面
<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="https"
android:host="www.example.com" />
現在打開網頁流量的應用程序,當我點擊這是關係到我們一個鏈接,但它不打開正確的頁面,它只是再次啓動應用程序。但我想直接打開webview應用程序中的正確頁面。
編輯:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//added
Intent intent = getIntent();
String action = intent.getAction();
Uri data = intent.getData();
但似乎未使用的變量操作和數據。 我像這樣加載webview(三種語言)。
//loads the main website
//sets the matching language
web2.clearCache(true);
String loc = Locale.getDefault().toString();
if (loc.startsWith("de")) {
web2.loadUrl("https://www.example.de");
} else if (loc.startsWith("nl")) {
web2.loadUrl("https://www.example.nl");
} else {
web2.loadUrl("https://www.example.com");
}
就像現在,你可以在編輯見上面,我加了一些東西,我的代碼(https://developer.android.com/training/app-links/deep-linking.html#testing-filters)但它不起作用。 – electromomo
我剛剛嘗試過使用adb shell,我開始-W -a android.intent.action.VIEW -d「https://www.example.com」,它工作。我得到了意圖選擇器,並開始我的應用程序,而不是鍍鉻 –
我在哪裏添加它?你能告訴我你的榜樣嗎? – electromomo