Start App Rewarded Ads (start.io) on Android
Start App Rewarded Ads (start.io) on Android
Rewarded Videos Ads are ads mostly shown in Games when we finish a particular level or task, or if we want to enable superpower then we have to view a video ad and then we get a reward from the ad.
Start App Ads are created with 4 types of Choices.
- Offerwall Ads
Start App Offerwall Ads for Android |
- Full page Ads (Interstitial Ads)
Start App Full Page Ads for Android |
- Rewarded Video Ads
Start App Rewarded Video Ads for Android |
- Automatic Ads (recommended) (Automatically shows the best ad for you).
Start App Automatic Ads for Android |
To show these Ads in Android, we will first create a button in Android Xml, and on a button click we will show our ads.
XML
<?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.RewardedAds">
<com.google.android.material.button.MaterialButton
android:id="@+id/start_app_rewarded"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="25dp"
app:layout_constraintTop_toTopOf="parent"
app:cornerRadius="8dp"
android:text="Start App rewarded"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/start_app_offerwall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="25dp"
app:layout_constraintTop_toBottomOf="@id/start_app_rewarded"
app:cornerRadius="8dp"
android:text="Start App Offerwall"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/start_app_fullpage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="25dp"
app:layout_constraintTop_toBottomOf="@id/start_app_offerwall"
app:cornerRadius="8dp"
android:text="Start App Fullpage"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/start_app_Automatic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="25dp"
app:layout_constraintTop_toBottomOf="@id/start_app_fullpage"
app:cornerRadius="8dp"
android:text="Start App Automatic"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Then in Java file we will load and show all ads on their respective button clicks.
Java file
public class RewardedAds extends AppCompatActivity {
Button rewarded_btn;
Button offerwall_btn;
Button fullpage_btn;
Button automatic_btn;
StartAppAd startAppAd_rewarded;
StartAppAd startAppAd_offerwall;
StartAppAd startAppAd_fullpage;
StartAppAd startAppAd_automatic;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rewarded_ads);
rewarded_btn = findViewById(R.id.start_app_rewarded);
offerwall_btn = findViewById(R.id.start_app_offerwall);
fullpage_btn = findViewById(R.id.start_app_fullpage);
automatic_btn = findViewById(R.id.start_app_Automatic);
StartAppSDK.init(this,"Your App Id",false);
StartAppSDK.setTestAdsEnabled(true);
StartAppAd.showSplash(this, savedInstanceState,
new SplashConfig()
.setTheme(SplashConfig.Theme.OCEAN)
.setAppName("Your Application Name")
.setLogo(R.drawable.app_logo) // resource ID
.setOrientation(SplashConfig.Orientation.LANDSCAPE)
);
startAppAd_rewarded = new StartAppAd(this);
startAppAd_offerwall = new StartAppAd(this);
startAppAd_fullpage = new StartAppAd(this);
startAppAd_automatic = new StartAppAd(this);
startAppAd_rewarded.loadAd(StartAppAd.AdMode.REWARDED_VIDEO);
startAppAd_offerwall.loadAd(StartAppAd.AdMode.OFFERWALL);
startAppAd_fullpage.loadAd(StartAppAd.AdMode.FULLPAGE);
startAppAd_automatic.loadAd(StartAppAd.AdMode.AUTOMATIC); // automatically loads the best ad for you.
startAppAd_rewarded.setVideoListener(new VideoListener() {
@Override
public void onVideoCompleted() {
Toast.makeText(RewardedAds.this, "100 coins granted for ad viewing", Toast.LENGTH_SHORT).show();
Log.e(TAG, "onVideoCompleted: " );
}
});
rewarded_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(startAppAd_rewarded.isReady())
{
startAppAd_rewarded.showAd();
}
}
});
offerwall_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(startAppAd_offerwall.isReady())
{
startAppAd_offerwall.showAd();
}
}
});
fullpage_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(startAppAd_fullpage.isReady())
{
startAppAd_fullpage.showAd();
}
}
});
automatic_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(startAppAd_automatic.isReady())
{
startAppAd_automatic.showAd();
}
}
});
}
}
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,
Subscribe to Harpreet studio on Youtube
Like Harpreet Studio on Facebook
Follow me on Instagram , Harpreet Studio on Instagram,
Install our Android app from Google Play store
No comments