Help Center Manage Your Account Ad Tag

How do I display mobile ads using Android WebView?

To display ads in native Android applications, you can use WebView (see also WebView API). Below is an example:

Add WebView in the layout

Here is an example WebView element in the activity layout:

Require Internet permission in the manifest


    
    ...

Setup WebView

Here is how to display the ad tag via WebView:
WebView myWebView = (WebView) findViewById(R.id.webview);
  myWebView.getSettings().setJavaScriptEnabled(true);
  myWebView.setBackgroundColor(Color.TRANSPARENT);
  String html = "";
  myWebView.loadData(html, "text/html", "utf-8");

Other Articles in Ad Tag

This section describes the ad tag (serving code) with basic and advanced settings. It includes common ad serving setup instructions and answers frequently asked questions when integrating the ad tag into your site, blog or app.

Cannot find an answer for your question? Ask our Customer Care team

Related