平成30/ 2018-10-23 19:49
Android/loadUrl で表示の「href="tel:0000」で電話できない。「href="maps.google.」で地図表示できない。


src/com/xxx/MainActivity.java
------------------
import android.net.Uri;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        String url;
        //Intent intent = new Intent(context, MainActivity.class);

        // タイトルバー消す
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        super.onCreate(savedInstanceState);


       //____
       //____ これ必要。もっと綺麗にかけるといいが。
       WebViewClient yourWebClient = new WebViewClient()
       {
           // Override page so it's load on my view only
           @Override
           public boolean shouldOverrideUrlLoading(WebView view, String url) {
                if (url.startsWith("tel:")) {
                    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url));
                    startActivity(intent);

                } else if(
                url.matches("^https?://maps\\.google\\..+")
                ){
                    Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));
                    intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
                    startActivity(intent);

               }else if(url.startsWith("http:") || url.startsWith("https:")) {
                   view.loadUrl(url);
               }
              return true;
            }
        };


        //リンクをタップしたときに標準ブラウザを起動させない
        // myWebView.setWebViewClient(new WebViewClient());


        //____
        //____ ここ必要。
        myWebView.setWebViewClient(yourWebClient);


        // Googleを表示する
        myWebView.loadUrl("http://xxx.com/sp/");



___ Thanks.
How to show native google map in webview in android?
http://stackoverflow.com/questions/9962469/how-to-show-native-google-map-in-webview-in-android

Override URL loading in Webview ? Android Tutorial
http://www.firstdroid.com/2010/08/05/override-url-loading-in-webview-android-tutorial/

http:// a href link not working in Android
http://stackoverflow.com/questions/15207717/http-a-href-link-not-working-in-android