Android 웹뷰에서 alert()사용하기. (+url 제거)

딱이·2021년 6월 10일
0
// WebView alert() 사용
webView.setWebChromeClient(new WebChromeClient() {
   // alert창 url 제거
    public boolean onJsAlert(WebView view, String url, String message, final android.webkit.JsResult result) {
    	new AlertDialog.Builder(MainActivity.this)
		.setTitle("")
        	.setMessage(message)
            	.setPositiveButton(android.R.string.ok, new AlertDialog.OnClickListener() {
                	public void onClick(DialogInterface dialog, int which) { result.confirm(); }
                 })
                 .setCancelable(false)
		 .create()
		 .show();

	return true;
    };
});
profile
뚝딱뚝딱 FE

0개의 댓글