아래와 같이 sdk 에서 서버를 통해 png 파일을 하나 받고
res/drawable/close_button.png 에 있는 close 버튼을 달아서 광고를 만들고 있는데요.
(마지막엔 webivew.loadData로 호출)
호출을 해도 아무것도 보이지가 않습니다!!!ㅠㅠ
대체 뭘 잘못한걸까요?
경로를 잘 못 한걸까요?
Log.d("INT", "startNumis2");
StringBuffer buffer = new StringBuffer();
buffer.append("<html><head><meta http-equiv='Content-Type' content='text/html charset=utf-8'>");
buffer.append("<script type='text/javascript'>");
buffer.append("function mrv(image){");
buffer.append("image.style['height'] =");
buffer.append(mDeviceInfo.getAdInterstitialSize().getHeight());
buffer.append(" + 'px';");
buffer.append("image.style['width'] =");
buffer.append(mDeviceInfo.getAdInterstitialSize().getWidth());
buffer.append(" + 'px'; ");
buffer.append("window.android.onAdImageReceived();}");
buffer.append("function trv(){window.android.onAdImageReceived();}");
buffer.append("function clickclosebutton(){window.android.oncloseButtonClick();}"); // by sujin
buffer.append("function err(){");
buffer.append("window.android.onAdImageFailed(); ");
buffer.append("var div_adimg = document.getElementById('adimg'); div_adimg=null;}");
buffer.append("</script>");
buffer.append("</head><body style='margin:0;'>");
buffer.append("<div id='adimg' style='position:absolute' z-index='2'>");
buffer.append("<img style='margin:0;' src=" + mNextAdInfo.getCreativeUrl() + "' onload='mrv(this);' onerror='err();'/>");
buffer.append("</div>"); // by sujin
buffer.append("<div style='position:absolute' z-index='1'>");
buffer.append("<img src="\"res/drawable/close_button.png\" alt='close' onclick='clickclosebutton()';/>");
buffer.append("</div>");
buffer.append("</body></html>");
후~ 이게 그냥 HTML 만들어서 웹으로 띄우면 보이는데, 왜 SDK 에서 LoadData 하면 보이지 않을까요?
webview.LoadData (creative, "html/text", "UTF-8"); 로하면 안되는 것인지.. (creative 변수에는 위에 html이 들어있습니다)
후~아래와 같이 html 이 만들어졌고, 이 html을 다른 activity 에서 오픈을 하게 되는구조입니다.
=> 아래 만들어진 html 구조 , 이것을 intent 이용해서 string 으로 값을 보내줌
<html><head><meta http-equiv='Content-Type' content='text/html charset=utf-8'><script type='text/javascript'>function mrv(image){image.style['height'] =480 + 'px';image.style['width'] =320 + 'px'; window.android.onAdImageReceived();}function mrv(){window.android.onAdImageReceived();}function clickclosebutton(){window.android.oncloseButtonClick();}function err(){window.android.onAdImageFailed(); var div_adimg = document.getElementById('adimg'); div_adimg=null;}</script></head><body style='margin:0;'><div id='adimg' style='position:absolute' z-index='2'><img style='margin:0;' src='http://50.18.124.80/Sites/1st/test.png' onload='mrv(this);' onerror='err();'/></div><div style='position:absolute' z-index='1'><img src="file://android_asset/close_button.png" alt='close' onclick='clickclosebutton()';/></div></body></html>
=> 액티비티에서 creative란 string 변수에 위 값이 들어가고 아래와 같이 로드했으나,,실패입니다.
webview.loadDataWithBaseURL("file:///android_asset/", creative, "text/html", "utf-8", "file:///android_asset/");




res 쪽은 참조가 불가능한 것으로 알고 있습니다. 대신 assets을 이용하시면 됩니다.
예를 들면 assets 디렉터리에 html/close_button.png 를 넣었을 때,
<img src="\"file:///android_asset/html//close_button.png\" alt='close' onclick='clickclosebutton()';/>
형태로 WebView에서 불러 올 수 있습니다.