Introduction
Android is one of the most popular operating systems for mobile. In this article, I will show you how to show interstitial ads every 20 seconds in an Android application using Android Studio.
Requirements
- Android Studio version 2.3.3
- Little bit XML and JAVA knowledge.
- Android Emulator (or) Android mobile
- Download link (Android Studio)
Steps to should be followed
Follow these steps to show interstitial ads every 20 seconds in an Android application. I have included the source code below.
Step 1
Open Android Studio and start a New Android Studio Project.

Step 2
You can choose your application name and choose the location where your project is to be stored. If you wish to use C++ for coding the project, mark the "Include C++ support", and click the "Next" button.

Now, select the version of Android and select the target Android devices.

Step 3
Now, add the activity and click the "Next" button.

Add Activity name and click "Finish".

Step 4
Go to activity_main.xml. This XML file contains the designing code for your Android app.

The XML code is given below.
- <?xml version="1.0" encoding="utf-8"?>
- <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="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="abu.interstitial_ad_every_20_seconds.MainActivity">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Android Ad_Mob!"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintLeft_toLeftOf="parent"
- app:layout_constraintRight_toRightOf="parent"
- app:layout_constraintTop_toTopOf="parent" />
- </android.support.constraint.ConstraintLayout>
Step 5
Go to (gradle scripts ⇒ build.gradle(moduleapp) and add the below code.

- apply plugin: 'com.android.application'
- android {
- compileSdkVersion 26
- buildToolsVersion "26.0.1"
- defaultConfig {
- applicationId "abu.interstitial_ad_every_20_seconds"
- minSdkVersion 19
- targetSdkVersion 26
- versionCode 1
- versionName "1.0"
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
- }
- dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
- exclude group: 'com.android.support',
- module: 'support-annotations'
- })
- compile 'com.android.support:appcompat-v7:26.+'
- compile 'com.android.support.constraint:constraint-layout:1.0.2'
- testCompile 'junit:junit:4.12'
- compile 'com.google.android.gms:play-services-ads:10.2.4'
- }







Amar JeetPosted Dec 16, 2018, 10:53 PM
How to show more than one intertitila ads on same page
Devin JonesPosted Dec 9, 2018, 1:26 PM
When i click the close button ( top left) of the intersitial ad then it will automatically redirect to my application how to prevent it
Deepak KumarPosted Aug 31, 2018, 10:56 PM
How can we use this thing with native ads too...???? reply on [email protected]
abdullah masudPosted Jun 29, 2018, 4:16 PM
Please help me brother?
abdullah masudPosted Jun 29, 2018, 4:15 PM
[email protected]
abdullah masudPosted Jun 29, 2018, 4:14 PM
How to call multiple interstitial ad new activity?
Abubackkar ShithikPosted Mar 22, 2018, 9:28 AM
Sure I can fix it can I get u r mail I'd
Jain 123Posted Mar 22, 2018, 9:14 AM
Code is working but ads goes on popping even after the app is running in background can you fix it