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
repositories {
mavenCentral()
}
dependencies {
// noinspection GradleDynamicVersion
implementation 'com.startapp:inapp-sdk:4.10.+'
}
Update AndroidManifest.xml
<!-- 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" />
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
<application>
<!-- TODO replace YOUR_APP_ID with actual value -->
<meta-data
android:name="com.startapp.sdk.APPLICATION_ID"
android:value="YOUR_APP_ID" />
</application>
@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]