티스토리 뷰

android

[android] onCreateWindow not working

sulkun 2017. 10. 17. 17:48
반응형

오늘 포스팅할내용은 WebChormClient에 onCreateWindow 가 왜 call될때가 


있고 안될때가 있는지 대해서 알아보는 시간을 가질텐데요


아주 간단해요


그냥 자세한 설명 없이 그냥그냥 할께요


저의 경우는 문제점이 을 몰라서 계속 해서 안드로이드만 건드리는거였는데요


알고보니 web 에서 만져야되더라구요 저는 


@Override
public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture, Message resultMsg){

//웹뷰 추가되는부분
final WebView newWebView = new WebView(view.getContext());
//WebView newWebView = new WebView(MainActivity.mContext);
configurateWebView(newWebView);
newWebView.setTag("subWebView");
newWebView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

MainActivity.customViewContainer.setVisibility(View.VISIBLE);
linParent.addView(newWebView);
MainActivity.customViewContainer.addView(linParent); // 화면에 보여질 수 있도록 add view
WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
transport.setWebView(newWebView);
resultMsg.sendToTarget();
    return true;
}

그리고 WebSetting 할떄

webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setSupportMultipleWindows(true);

요렇게 셋팅값을 줬어요 


움..그리고 MainActivity.customViewContainer 이부분이 Main RelativeLayout 에 추가 되는 부분이에요


리고고 웹에서 window.open or location.href=''로 해서 값을 줘야만 onCreate를 타더군요


혹시나 못하신분은 참고해보셔요~~~


그럼이만



반응형
댓글