From bd98497cee868ec2c37f647545b06ef308cf9c40 Mon Sep 17 00:00:00 2001 From: zhuyangyang Date: Mon, 14 Dec 2020 17:59:08 +0800 Subject: [PATCH] [BugFix] Fix the protocl parse failed in webdemo module --- webdemo/src/main/assets/page.html | 8 ++++---- .../src/main/java/com/spinytech/webdemo/WebActivity.java | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/webdemo/src/main/assets/page.html b/webdemo/src/main/assets/page.html index 1035bcc..87fd35b 100644 --- a/webdemo/src/main/assets/page.html +++ b/webdemo/src/main/assets/page.html @@ -7,13 +7,13 @@
-

LOCAL SYNC

+

LOCAL SYNC


-

PLAY MUSIC

+

PLAY MUSIC


-

STOP MUSIC

+

STOP MUSIC


-

OPEN PIC

+

OPEN PIC


\ No newline at end of file diff --git a/webdemo/src/main/java/com/spinytech/webdemo/WebActivity.java b/webdemo/src/main/java/com/spinytech/webdemo/WebActivity.java index f351cfb..1abd45c 100644 --- a/webdemo/src/main/java/com/spinytech/webdemo/WebActivity.java +++ b/webdemo/src/main/java/com/spinytech/webdemo/WebActivity.java @@ -32,8 +32,9 @@ protected void onCreate(Bundle savedInstanceState) { public void dispatchAction(String url) { - if (url.indexOf("your_protocol://") >= 0) { - String command = url.substring("your_protocol://".length()); + int index = url.indexOf("your_protocol://"); + if (index >= 0) { + String command = url.substring(index + "your_protocol://".length()); try { LocalRouter.getInstance(MaApplication.getMaApplication()).route(this, new RouterRequest.Builder(this).url(command).build()); } catch (Exception e) { @@ -45,7 +46,7 @@ public void dispatchAction(String url) { class MyWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { - if (!TextUtils.isEmpty(url) && url.startsWith("your_protocol://")) { + if (!TextUtils.isEmpty(url) && url.contains("your_protocol://")) { dispatchAction(url); } else { mContentWv.loadUrl(url);