Skip to content

Android SDK Setup

Aleksandr Chatsky edited this page Jan 4, 2019 · 7 revisions

Initialization

In order to receive any type of advertisement, you should initialize Appmediation SDK first. To initialize Appmediation SDK, call AMSDK.init method as mentioned below and it takes the first parameter an Activityinstance and the second parameter is the key that you can find in your Appmediation dashboard after you register your app:

AMSDK.init(activity, "YOUR_APP_KEY");

N.B.: Get your app key from here.

Auto Loading

Appmediation SDK supports banners, interstitials and rewarded videos for auto-loading:

AdType.BANNER
AdType.INTERSTITIAL
AdType.REWARDED_VIDEO

If you want Appmediation SDK to handle ad requests and loadings for you, you need to set ad types to auto load. You can do it by calling method below:

AMSDK.setAutoLoad(AdType.BANNER, AdType.INTERSTITIAL, AdType.REWARDED_VIDEO);

or if you want to autoload single or two formats, you can do like this:

AMSDK.setAutoLoad(AdType.BANNER);

GDPR

You need to obtain end-users' consent from EU/EEA zone users before using our advertising services. We have developed two options you can use:

Automatic Consent Collection

Appmediation SDK comes with this function enabled by default. With this functionality, we check the user's location and if the user is in the EU/EEA zone, we show them the consent message. If the user is outside of the EU/EEA zone, we do not bother them with GDPR consent message at all!

If you want to disable this functionality and use the manual collection, please disable it by:

AMSDK.showConsentAutomatically(false);

Manual Consent Collection

Consent Window

Each time when you are required to collect end-user data consent, you can call the consent window. You can display Appmediation consent window any time you would like. You can also check if the Appmediation SDK has a response saved from the user by wasConsentSet(). You can find an example snippet below:

if (!AMSDK.wasConsentSet(activity)) {
    AMSDK.showGdprNotice(activity, new GdprDialogListener() {
        @Override
        public void onOptionSelected(boolean gdprConsent) {
            // User has selected an option to agree or to disagree
        }

        @Override
        public void onCancelled() {
            // Window was cancelled
        }
    });
}

N.B: You can also use this method without setting any listeners (example: AMSDK.showGdprNotice(activity, null))

N.B: You don't have to manually set GDPR value for Appmediation when using AMSDK.showGdprNotice method, it will be set automatically.

Consent Function

If you have your own GDPR message and collect consent from your own view, please pass the collected consent value to the method below and you are all set!

AMSDK.setGdprConsent(activity, userConsent);

Possible values for userConsent are listed below;

- AMSDK.GdprConsent.AGREE
- AMSDK.GdprConsent.DISAGREE
- AMSDK.GdprConsent.NOT_REQUIRED
- AMSDK.GdprConsent.UNKNOWN

Integration Checker

Appmediation SDK 2.0 includes a tool for verifying the integration of adapters and ad network SDKs. It checks the compatibility between adapters, SDK versions and manifest settings. In order to check your integration and get the report from the debugger, please call method below and pass as a parameter Activity instance:

AMIntegrationChecker.validateIntegration(activity);

Test Mode

If you want to test your integration with our test ads, set test mode by calling:

AMSDK.setTestMode(true); // Set before initialization

N.B.: You can also enable/disable test mode from your dashboard.

User Identifier

You can set a user identifier by calling:

AMSDK.setUserIdentifier("player1234");

N.B: Currently this feature is only used by a server to server rewarded video callbacks. You MUST set this value if you want to use the server to server callbacks.

Clone this wiki locally