package study.sol.webviewex;

import java.security.PublicKey;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class WebViewExActivity extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
	
	WebView wv;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        wv=(WebView) findViewById(R.id.webView1);
        
        WebSettings  ws =wv.getSettings();
        ws.setSaveFormData(true);
        ws.setSavePassword(false);
        ws.setSupportZoom(true);
        ws.setJavaScriptEnabled(true);
        
        wv.addJavascriptInterface(new Myclass(),"demo");
        wv.setWebViewClient(new ViewClient());
        
       // wv.loadUrl("http://m.naver.com");
       // wv.loadUrl("file:///android_asset/index.html");
        wv.loadUrl("file:///android_asset/phonecall.html");
    
        
    }
    
    
     public class ViewClient extends WebViewClient{

		@Override
		public void onPageFinished(WebView view, String url) {
			// TODO Auto-generated method stub
			android.util.Log.e("WebView", "페이지 로딩 끝");
			super.onPageFinished(view, url);
		}

		@Override
		public void onPageStarted(WebView view, String url, Bitmap favicon) {
			// TODO Auto-generated method stub
			android.util.Log.e("WebView", "페이지 로딩 시작");
			super.onPageStarted(view, url, favicon);
		}

		@Override
		public boolean shouldOverrideUrlLoading(WebView view, String url) {
			// TODO Auto-generated method stub
			wv.loadUrl(url);
			return super.shouldOverrideUrlLoading(view, url);
		}
    	    	    	 
     }

 
     public class Myclass {
    	 
    	  public void cellPhone(String telno){
    		  
    		Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+telno));
    		startActivity(intent);
    		
    	  }
     }
	//@Override
//	public void onClick(View v) {
		// TODO Auto-generated method stub


	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		
	}
		
//	}
    
   }
