What is StartApp?

StartApp is an alternative of Google AdSense and in a short sentence ad service provider for mobile and web. StartApp provides both publisher and advertiser service, where the publisher can post an ad for their company and advertiser(developers) can show that ads and earn some bucks. There are lots of other alternatives for Google AdSense like media.net, inmobi.com, airpush and so on. Today we will be showing the way to integrate ad in android app provided by StartApp company.

 

Getting Started

First, we need a StartApp advertiser account.

 

 

Step 2: Register as Advertiser
Step 3: After email, verification add an app by providing play store link

 

 

 

Step 4: Get the app id from the added app list and save it to use later

 

Setup StartApp in Android:

Step 1: Open a new empty project in the android studio and provide it a relevant name with a package

 

 

Step 2: Write Application name and Company Domain, then click next and next until project dashboard opened.

 

 

Step 3: Add the following repositories and dependencies to your app-level build.gradle file
android {
    repositories{
        jcenter()
    }
}
dependencies {
    compile 'com.startapp:inapp-sdk:3.6.2'
}

 

Step 4: Add the following permissions under the main <manifest> element:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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" />

The last four permissions are optional, but highly recommended for better performance.
StartApp SDK doesn’t request location updates proactively but only uses the last known location.

Step 5: Add the following activities under the <application> element
<activity android:name="com.startapp.android.publish.ads.list3d.List3DActivity"
          android:theme="@android:style/Theme" />

<activity android:name="com.startapp.android.publish.adsCommon.activities.OverlayActivity"
          android:theme="@android:style/Theme.Translucent"
          android:configChanges="orientation|keyboardHidden|screenSize" />

<activity android:name="com.startapp.android.publish.adsCommon.activities.FullScreenActivity"
          android:theme="@android:style/Theme"
          android:configChanges="orientation|keyboardHidden|screenSize" />

 

Step 6: Add the following service receiver under <application> the element
<service android:name="com.startapp.android.publish.common.metaData.PeriodicMetaDataService" />
<service android:name="com.startapp.android.publish.common.metaData.InfoEventService" />
<receiver android:name="com.startapp.android.publish.common.metaData.BootCompleteListener" >
	<intent-filter>
		<action android:name="android.intent.action.BOOT_COMPLETED" />
	</intent-filter>
</receiver>

 

Step 7: Open MainActivity class from src folder and add the following code in your main activity before calling setContentView() call the static function
StartAppSDK.init(this, "Your App ID", true);
Replace “Your App ID” with your own value provided in the developers’ portal.

 

To find your application ID, click on the “Apps and Sites” tab on the left pane and choose the relevant ID from your app list:

 

 

Step 8: If you want to show a special interstitial ad on app resume then initialize startapp SDK with true command. Or if you don’t then initialize startapp SDK with false command.

Please notice – if you initialize the SDK in a service, you must do it on the service’s main thread.

Integrate Banner Ad:

Step 1: After that open activity_main.xml from res/layout folder and add the following code.
You can position the banner ad anywhere according to your needs. In our project, we have implemented it in bottom.
<com.startapp.android.publish.ads.banner.Banner 
          android:id="@+id/startAppBanner"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"/>
Step 2: Now build and run, you will be able to see the code at bottom of our layout or the place where the ad is located in your XML.

Splash Ad Integration:

Splash ad is highly recommended for high CPM from StartApp integration. It has been stated that splash ad will get high CPM for your app.
StartApp Splash Ad is a top performing ad unit, presenting the industry’s highest CPM’s
By default, Splash Ad is always turned on for app integration.
To customize default splash ad integration, add the following code after startapp SDK initialization.
StartAppAd.showSplash(this, savedInstanceState, 
          new SplashConfig()
                 .setTheme(SplashConfig.Theme.OCEAN)
                 .setAppName("Your Application Name")  
                 .setLogo(R.drawable.your_360x360_logo)   // resource ID
                 .setOrientation(SplashConfig.Orientation.LANDSCAPE)
);
To disable default splash ad integration, add the following code after startapp SDK initialization
StartAppSDK.init(this,"Your App Id", true);
StartAppAd.disableSplash();

Interstitial Ad Integration:

There are three kinds of interstitial on the planet of StartApp. There are –
1. Standard Interstitials
2. Exit Ads
3. Autostitials
Standard Interstitial ad can be shown anywhere by adding followed code snippet.
StartAppAd.showAd(this);
If you want to show an interstitial ad on click of certain button or location, then add the above-mentioned code inside event listener for certain button or layout. As example –
public void btnOpenActivity (View view){
    Intent nextActivity = new Intent(this, NextActivity.class);
    startActivity(nextActivity);
    StartAppAd.showAd(this);
}
Exit Interstitial ad can be shown on the time of exit. If you want to show, then you have to add the following code inside the onBackPressed function.
@Override
public void onBackPressed() {
	StartAppAd.onBackPressed(this);
	super.onBackPressed();
}
Autostitials ad will be shown after a certain period of time. In that case, you have too little bit customize interstitial with the following code.
StartAppAd.setAutoInterstitialPreferences(
                  new AutoInterstitialPreferences()
                  .setSecondsBetweenAds(60)                  
           );

activity frequency

You can set a minimum number of activities between consecutive Autostitial Ads.
For example, show an Autostitial after every 3 activities:

StartAppAd.setAutoInterstitialPreferences(
                  new AutoInterstitialPreferences()
                  .setActivitiesBetweenAds(3)                  
           );

Time-frequency and activity frequency can be used together.

Please notice – If you want to use Autostitial Ads and yet to show an Interstitial in a specific location, call StartAppAd.disbleAutoInterstitial(); before calling StartAppAd.showAd, otherwise two ads might be displayed together. Remember to call StartAppAd.enableAutoInterstitial(); afterthat to reanable Autostitial Ads.