forked from FreeDGroup/ChinaMobileAndroidSample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebViewClientImpl.java
More file actions
36 lines (28 loc) · 1.12 KB
/
Copy pathWebViewClientImpl.java
File metadata and controls
36 lines (28 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.example.jiwonyoon.widgetandroidtest;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class WebViewClientImpl extends WebViewClient {
private Activity activity = null;
public WebViewClientImpl(Activity activity) {
this.activity = activity;
}
@Override
public void onPageFinished(WebView view, String url) {
String setScript = "window.webViewBridge.setEnv('android')";
view.loadUrl("javascript:" + setScript);
String script = "window.webViewBridge.send({type:'initialize', provider_id: 13})";
view.loadUrl("javascript:" + script);
super.onPageFinished(view, url);
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String url) {
// handle https://widget-cm.travelflan.com.cn url only
if(url.indexOf("https://widget-cm.travelflan.com.cn") > -1 ) return false;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
activity.startActivity(intent);
return true;
}
}