Rapid Subscribe Android App

Rapid Subscribe Android App
Rapid Subscriber

Recent Posts

Start App Interstitial Ads (start.io) in Android

Start App Interstitial Ads (start.io) on Android



Interstitials ads are Full-Screen ads that are shown mostly when you finish some in an app. 
For example, show this ad when someone saves a photo after editing in a photo editing app or downloads a photo, etc. 

Start App Interstitial
Start App Interstitial



In this post, we will learn about
  • Interstitial Ads
  • Exit ads
  • Auto interstitials

We will load Interstitial Ads with a button click, you can load it according to your app UI.



Create a button in your XML file to create a click listener on it and load interstitial ads.

XML file
 <?xml version="1.0" encoding="utf-8"?>  
 <androidx.constraintlayout.widget.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=".StartAppAds.InterstitialAds">  
   <com.google.android.material.button.MaterialButton  
     android:layout_width="match_parent"  
     android:layout_height="wrap_content"  
     android:text="Start App Interstitial"  
     app:layout_constraintTop_toTopOf="parent"  
     android:layout_margin="25dp"  
     app:cornerRadius="8dp"  
     android:id="@+id/start_interstitial_button"/>  
 </androidx.constraintlayout.widget.ConstraintLayout>  

Then in your Java file. Load Interstitial ads on a Button Click.

Java file
 public class InterstitialAds extends AppCompatActivity {  
   Button interstitial_btn;  
   StartAppAd startAppAd;  
   @Override  
   protected void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
     setContentView(R.layout.activity_interstitial_ads);  
     StartAppSDK.init(this,"",false);  
     StartAppSDK.setTestAdsEnabled(true);  
     interstitial_btn = findViewById(R.id.start_interstitial_button);  
     startAppAd = new StartAppAd(this);  
     startAppAd.loadAd(new AdEventListener() {  
       @Override  
       public void onReceiveAd(@NonNull Ad ad) {  
         Log.e("TAG", "onReceiveAd: " );  
         // startAppAd.showAd();  
       }  
       @Override  
       public void onFailedToReceiveAd(@Nullable Ad ad) {  
         Log.e("TAG", "onFailedToReceiveAd: "+ad.errorMessage );  
       }  
     });  
     interstitial_btn.setOnClickListener(new View.OnClickListener() {  
       @Override  
       public void onClick(View view) {  
         if(startAppAd.isReady())  
         {  
           //also you have to tell user that ad is going to shown to users  
           ProgressDialog dialog = new ProgressDialog(InterstitialAds.this);  
           dialog.setTitle("Ad");  
           dialog.setMessage("Loading Ad...");  
           dialog.setCancelable(false);  
           dialog.show();  
           Handler handler = new Handler();  
           handler.postDelayed(new Runnable() {  
             @Override  
             public void run() {  
               dialog.dismiss();  
               startAppAd.showAd();  
               //goto next activity  
             }  
           },1500);  
         }  
         else  
         {  
           //goto next activity  
         }  
       }  
     });  
   }  
 }  

For Auto Interstitials and Exit Ads

Auto interstitials are interstitial ads and it loads every time when you enter or exit from an activity. You can set the time and frequency of ads to be shown according to your choice.



Exit interstitials are interstitial ads shown when you exit from your activity, just call this code in on the back pressed of activity.

java file
 public class InterstitialAds extends AppCompatActivity {  
   StartAppAd startAppAd;  
   @Override  
   protected void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
     setContentView(R.layout.activity_interstitial_ads);  
     StartAppSDK.init(this,"",false);  
     StartAppSDK.setTestAdsEnabled(true);  
     StartAppAd.enableAutoInterstitial();  
     // seconds of time when new autoad will be shown  
     StartAppAd.setAutoInterstitialPreferences(  
         new AutoInterstitialPreferences()  
             .setSecondsBetweenAds(60)  
     );  
     // activities of which ads are shown  
     StartAppAd.setAutoInterstitialPreferences(  
         new AutoInterstitialPreferences()  
             .setActivitiesBetweenAds(3)  
     );  
   }  
   @Override  
   public void onBackPressed() {  
     StartAppAd.onBackPressed(this); // whenever this backpress calls  
                         // it shows an ad and then perform action
     super.onBackPressed();  
   }  
 }  




Follow us for more posts like this, 
Subscribe to Harpreet studio on Youtube  
Like Harpreet Studio on Facebook  
Follow me on Instagram, Harpreet Studio on Instagram,

No comments