채택완료

안드로이드 웹뷰?쪽도 아시는분

2017-05-31 (수) 16:55:36 4,815

안녕하세요 질문좀 드리고자합니다.

이번에 웹뷰로 하나 어플을 만들었는데요

<a href="tel:010-1111-5570" >

이미지

</a>

이런식으로 웹에서는 작업을했는데요 

 그냥 인터넷에서는 잘되는데 웹뷰에서는 

다음 이유로 tel:010-1111-5570의 웹페이지를 로드할 수 없습니다

라고나옵니다 ㅠㅠ

구글링 해도 방법을 잘모르겟고

아래링크  설명좀 해주시면 감사하곗습니다

http://frog-rammer.blogspot.kr/2014/07/web-view.html 

다 넣었는데 안됩니다 ㅠㅠ

AndroidManifest.xml 부분 

MainActivity.java 부분

Copy
package com.mobile3cm.alex.webview;import android.app.Activity;import android.app.ProgressDialog;import android.content.Intent;import android.net.Uri;import android.os.Build;import android.os.Message;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.util.Log;import android.view.KeyEvent;import android.webkit.JavascriptInterface;import android.webkit.ValueCallback;import android.webkit.WebChromeClient;import android.webkit.WebSettings;import android.webkit.WebView;import android.webkit.WebViewClient;import android.widget.Toast;import java.net.URL;public class MainActivity extends Activity {    WebView webView;    URL uri;    private ValueCallback<Uri> filePathCallbackNormal;    private ValueCallback<Uri[]> filePathCallbackLollipop;    private final static int FILECHOOSER_NORMAL_REQ_CODE = 1;    private final static int FILECHOOSER_LOLLIPOP_REQ_CODE = 2;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        startActivity(new Intent(MainActivity.this, SplashActivity.class));        webView = (WebView) findViewById(R.id.wv_mainWebview);        String url = "http://jmoney119.cafe24.com";        try {            uri = new URL(url);            webView.setWebChromeClient(new WebChromeClient() {                // For Android < 3.0                public void openFileChooser(ValueCallback<Uri> uploadMsg) {                    Log.d("MainActivity", "3.0 <");                    openFileChooser(uploadMsg, "");                }                // For Android 3.0+                public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {                    Log.d("MainActivity", "3.0+");                    filePathCallbackNormal = uploadMsg;                    Intent i = new Intent(Intent.ACTION_GET_CONTENT);                    i.addCategory(Intent.CATEGORY_OPENABLE);                    i.setType("image/*");                    startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_NORMAL_REQ_CODE);                }                // For Android 4.1+                public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {                    Log.d("MainActivity", "4.1+");                    openFileChooser(uploadMsg, acceptType);                }                // For Android 5.0+                public boolean onShowFileChooser(                        WebView webView, ValueCallback<Uri[]> filePathCallback,                        WebChromeClient.FileChooserParams fileChooserParams) {                    Log.d("MainActivity", "5.0+");                    if (filePathCallbackLollipop != null) {                        filePathCallbackLollipop.onReceiveValue(null);                        filePathCallbackLollipop = null;                    }                    filePathCallbackLollipop = filePathCallback;                    Intent i = new Intent(Intent.ACTION_GET_CONTENT);                    i.addCategory(Intent.CATEGORY_OPENABLE);                    i.setType("image/*");                    startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_LOLLIPOP_REQ_CODE);                    return true;                }                @Override                public boolean onCreateWindow(WebView view, boolean dialog, boolean userGesture, Message resultMsg) {                    // return true or false after performing the URL request                    WebView newWebView = new WebView(MainActivity.this);                    view.addView(newWebView);                    WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;                    transport.setWebView(newWebView);                    resultMsg.sendToTarget();                    newWebView.setWebViewClient(new WebViewClient() {                        @Override                        public boolean shouldOverrideUrlLoading(WebView view, String url) {                            Intent browserIntent = new Intent(Intent.ACTION_VIEW);                            browserIntent.setData(Uri.parse(url));                            startActivity(browserIntent);                            return true;                        }                    });                    return true;                }            });            webView.setWebViewClient(new WebViewClient() {                @Override                public boolean shouldOverrideUrlLoading(WebView view, String url) {                    view.loadUrl(url);                    return false;                }            });            WebSettings webSettings = webView.getSettings();            webSettings.setJavaScriptEnabled(true);            webView.loadUrl(url);        }catch (Exception e){        }    }    public boolean shouldOverrideUrlLoading(WebView view, String url) {        if(url.startsWith("tel:010-1111-5570")){            Intent dial = new Intent(Intent.ACTION_VIEW, Uri.parse(url));            //현재의 activity 에 대하여 startActivity 호출            startActivity(dial);            return true;        }        view.loadUrl(url);        return true;    }    @Override    public boolean onKeyDown(int keyCode, KeyEvent event) {        if((keyCode == KeyEvent.KEYCODE_BACK) && webView.canGoBack()) {            webView.goBack();            return true;        }        return super.onKeyDown(keyCode, event);    }    protected void onActivityResult(int requestCode, int resultCode, Intent data) {        if (requestCode == FILECHOOSER_NORMAL_REQ_CODE) {            if (filePathCallbackNormal == null) return ;            Uri result = (data == null || resultCode != RESULT_OK) ? null : data.getData();            filePathCallbackNormal.onReceiveValue(result);            filePathCallbackNormal = null;        } else if (requestCode == FILECHOOSER_LOLLIPOP_REQ_CODE) {            if (filePathCallbackLollipop == null) return ;            filePathCallbackLollipop.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, data));            filePathCallbackLollipop = null;        }    }}
|

답변 1개

채택된 답변
+20 포인트
2017-05-31 (수) 18:01:24

https://www.google.co.kr/#newwindow=1&q=%EC%9B%B9%EB%B7%B0+tel+%EC%B2%98%EB%A6%AC&spf=1496221218796 

안드로이드 웹뷰의 경우 tel, sms 이런 기능들은 별도 처리를 해주셔야 됩니다.

검색하면 많은 소스가 나오니 맞는 소스를 선택하셔서 적용하시면 될거 같습니다. 

답변을 작성하려면 로그인이 필요합니다.