Bonjour,
comment est ce que je peux avoir deux "validations" dans mon shouldOverrideUrlLoading ?
Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 public boolean shouldOverrideUrlLoading(WebView view, String url) { 1e validation=> if (estConnecte) { // return false to let the WebView handle the URL return false; } else { String offline = ""; // show the proper "not connected" message view.loadData(offline, "text/html", "utf-8"); // return true if the host application wants to leave the current // WebView and handle the url itself return true; } 2e validation=> if (url != null && url.startsWith("http://")) { view.getContext().startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse(url))); return true; } else { return false; } }
Partager