Skip to content

daniel3133/StartApp_InApp_SDK_Example

 
 

Repository files navigation

StartApp SDK Example

This project provides an example of the StartApp SDK integration for Android.

The example application contains the following ads:

  • Banner
  • Interstitial ad
  • Rewarded video
  • RecyclerView with Banner
  • RecyclerView with NativeAd

Add dependency

app/build.gradle

dependencies {
    // noinspection GradleDynamicVersion
    implementation 'com.startapp:inapp-sdk:4.6.+'
}
<!-- Add these permissions for better ad targeting -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.BLUETOOTH" />

<application>
    <!-- TODO replace YOUR_APP_ID with actual value -->
    <meta-data
        android:name="com.startapp.sdk.APPLICATION_ID"
        android:value="YOUR_APP_ID" />
</application>

Set up test ad

MainActivity.java

@Override
protected void onCreate(Bundle state) {
    super.onCreate(state);

    // NOTE always use test ads during development and testing
    StartAppSDK.setTestAdsEnabled(BuildConfig.DEBUG);

    setContentView(R.layout.main);
}

Add Banner into xml layout

<com.startapp.sdk.ads.banner.Banner
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
public void someMethod() {
    // start your next activity
    startActivity(new Intent(this, OtherActivity.class));

    // and show interstitial ad
    StartAppAd.showAd(this);
}
public void showRewardedVideo() {
    final StartAppAd rewardedVideo = new StartAppAd(this);

    rewardedVideo.setVideoListener(new VideoListener() {
        @Override
        public void onVideoCompleted() {
            // Grant the reward to user
        }
    });

    rewardedVideo.loadAd(StartAppAd.AdMode.REWARDED_VIDEO, new AdEventListener() {
        @Override
        public void onReceiveAd(Ad ad) {
            rewardedVideo.showAd();
        }

        @Override
        public void onFailedToReceiveAd(Ad ad) {
            // Can't show rewarded video
        }
    });
}

For any question or assistance, please contact us at [email protected].

About

StartApp InApp Android SDK Example Project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%