5

I want to add leadbolt banner ad in a webview. Here is the ad code below

<script type="text/javascript" src="http://ad.leadboltads.net/show_app_ad.js?section_id=xxxxxxxxx"></script>

How will I add this?

2 Answers 2

3

WebView have a method called loadData(). Allow webview load html code directly.You could have a try.

String js_str = "<script type='text/javascript' src='http://ad.leadboltads.net/show_app_ad.js?section_id=xxxxxxxxx'></script>"

WebView webview = new WebView();

webview.loadData(js_str, null, null);
Sign up to request clarification or add additional context in comments.

1 Comment

You may want to escape the quotes within your string.
0

try this

WebView wv = (WebView)findViewById(R.id.webViewad); 
wv.getSettings().setJavaScriptEnabled(true);
StringBuilder htmlData = new StringBuilder("<html>"); 
htmlData.append("<head><title>Ad</title></head>"); 
htmlData.append("<body>"); 
htmlData.append("<script type=\"text/javascript\" 
src=\"http://ad.leadboltads.net/show_app_ad.js?section_id=YOUR_ID\"></script>"); 
htmlData.append("</body>"); 
htmlData.append("</html>"); 
wv.loadData(htmlData.toString(),"text/html", "ISO 8859-1");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.