Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Javascript In Webview In Android

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?

like image 895
Zahid Habib Avatar asked Oct 07 '22 18:10

Zahid Habib


1 Answers

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);
like image 102
wayne_bai Avatar answered Oct 10 '22 01:10

wayne_bai