I want to show Interstitial ad on my webview android app but I am unable to implement it.
I have an webview app which is fully online, with no offline pages or any button or menu.
I don't want to show Interstitial ad on starting or closing app.
- Ad should be shown when user browse my website using that webview app.
- I thought to use Interstitial ad after x minutes, but I have learned Interstitial ad after x minutes is not a good idea from here and here.
- Then how can I show Interstitial ad on my app as I told, I don't have any button or menu but only a website to browse.
- Please suggest me how can I use Interstitial ad on my webview app.
- I tried and successfully implement BANNER ad. with the help of stackoverflow question-answer and Google (code given below) but failed to implement Interstitial ad by any means
- I'm very much new in this sector so please suggest me with detail process means where put code etc.
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.xxxx.yyyyy.MainActivity"
android:layout_gravity="center"
android:id="@+id/fl">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/wv"/>
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-xxxxx/xxxxxx">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
Mainactivity java
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.ads.MobileAds;
MobileAds.initialize(this, "xxxxxx~xxxxxx");
AdView adView = (AdView)findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("xxxxxxx")
.build();
adView.loadAd(adRequest);
using firebase (build.gradle)
compile 'com.google.firebase:firebase-ads:10.2.6'