Android InApp NH Documentation - yanivav/Documentation GitHub Wiki
NOTES:
- The code samples in this document can be copy/pasted into your source code
- If you have any questions, contact us via [email protected]
##Step 1, Adding the SDK JAR to Your Eclipse Project
Copy the SDK jar file from the SDK zip to the “libs” directory of your project.
Under the <application> element, add your new activities:
<activity android:name="com.startapp.android.publish.list3d.List3DActivity"
android:taskAffinity="YOUR_PACKAGE_NAME.AppWall"
android:theme="@android:style/Theme" />
<activity android:name="com.startapp.android.publish.AppWallActivity"
android:theme="@android:style/Theme.Translucent"
android:taskAffinity="YOUR_PACKAGE_NAME.AppWall"
android:configChanges="orientation|keyboardHidden" />
##Step 3, Initialization In your main activity, go to the ``OnCreate`` method and before calling ``setContentView()`` call the static functions:NOTE: Replace YOUR_PACKAGE_NAME with your actual package name as declared in your manifest in both activities. For example, if your package name is "com.test.example", replace YOUR_PACKAGE_NAME with "com.test.example.AppWall".
StartAppAd.init(this, "Your Developer Id", "Your App ID");
Replace "Your Developer Id" and "Your App ID" with your own values provided in the developers’ portal.
After logging in, your developer ID will be at the top right-hand corner of the page:
To find your application ID, click on the at the top of the main screen and then choose the relevant ID from your app list:
NOTE: This code places a View inside your Activity. You also have the option to add additional attributes for placing it in the desired location in your Activity.
If you wish to add a specific type of banner, please refer to the Advanced Usage.
##Step 5, Showing Interstitial Ads Interstitial Ads are displayed before or after a certain content page or action, such as upon entering a stage, between stages, while waiting for an action, upon exiting the application and more.####Initializing the StartApp Ad Object In your Activity, create a member variable, as follows:
private StartAppAd startAppAd = new StartAppAd(this);
Override the onResume()
method and add the method startAppAd.onResume()
AFTER the method super.onResume()
:
@Override
public void onResume() {
super.onResume();
startAppAd.onResume();
}
####Showing Exit Ads Add the following code to show an ad upon exiting your application.
To show an ad when pressing the 'Back' button, override the onBackPressed()
method and add the method startAppAd.onBackPressed()
BEFORE the method super.onBackPressed()
:
@Override
public void onBackPressed() {
startAppAd.onBackPressed();
super.onBackPressed();
}
####Showing Interstitials Add the following code to the appropriate place(s) in the activity in which you would like to show the Ad:
startAppAd.showAd(); // show the ad
startAppAd.loadAd(); // load the next ad
NOTE:
loadAd()
must be called immediately aftershowAd()
. This will load the next Ad.
The following is an example of showing an Interstitial Ad between Activities:
public void btnOpenActivity (View view){
startAppAd.showAd();
startAppAd.loadAd();
Intent nextActivity = new Intent(this, NextActivity.class);
startActivity(nextActivity);
}
Splash Screen Mode | Description |
---|---|
Template Mode | StartApp In-Ad provides a pre-defined template in which you can place your own creatives, such as application name, logo and loading animation. |
User-Defined Mode | Please refer to the Advanced Usage |
####Adding the Splash Screen
In the OnCreate
method of your Activity, after calling StartAppAd.init
and before setContentView
, call the following static function:
StartAppAd.showSplash(this, savedInstanceState);
Apply the following parameters:
- this: The context (Activity)
-
savedInstanceState: The Bundle parameter passed to your
onCreate(Bundle savedInstanceState)
method
If you wish to customize or use a different splash screen, please refer to the Advanced Usage.
##Step 7, Integrating the Slider After calling ```setContentView()```, in the ```OnCreate()``` method of your main activity, call the static function: ```java StartAppAd.showSlider(this); ```If you would like the Slider to appear in additional activities, repeat this step in each one of the activities you would like it to show in. The Slider cannot be implemented in activities with a Dialog Theme: (android:theme="@android:style/Theme.Dialog")
##Step 8, Obfuscation (Optional) Obfuscation protects an application from reverse-engineering or modification by making it harder for a third-party to access your source (decompiled) code.NOTE: for better user experience, and in order to avoid reload of the Slider when rotating the phone, it is recommended to go back to your manifest file and add the following attribute to any <activity> element that you added the Slider to:
android:configChanges="orientation|screenSize"
StartApp In-Ad is already obfuscated! Therefore, if you did not obfuscate your application using ProGuard™, then you can skip this step. If you have obfuscated your application using ProGuard, then use the following in the ProGuard configuration file:
-keep class com.startapp.** {
*;
}
-keepattributes Exceptions, InnerClasses, Signature, Deprecated, SourceFile,
LineNumberTable, *Annotation*, EnclosingMethod
-dontwarn android.webkit.JavascriptInterface
-dontwarn com.startapp.**
For a full integration guide, please refer to the "Using Native Ads" section under the "Advanced Usage" page.
##Enjoy Higher eCPM with Demographic-Targeted Ads If you know your user's gender or age, StartApp can use it to serve better-targeted ads which can increase your eCPM and revenue significantly.Example
@Override
public void onResume() {
super.onResume();
startAppAd.loadAd(new AdPreferences()
.setAge(18)
.setGender("Male"));
startAppAd.onResume();
}
1 In your onResume()
method, use the AdPreferences object instead of just calling startAppAd.onResume()
as described above. Use setAge()
with your user's real age, and setGender()
with your user's real gender – "Male" or "Female".
2 Do the same for each loadAd()
call in your project.