This guide contains all the information needed by Android developers to integrate with the AdFlacon Network. The guide will also show examples and code snippets on how to perform the integration.
Prerequisites
- Android API v16 or above
- Android Studio v2.0.0 or above.
- Gradle version v3.0.0 or above.
- Google play services ads v8.0.0 or above.
Adding the SDK to your project
You can add AdFalcon Android SDK to your project by implementing one of the following ways:
Pulling the SDK via maven (Recommended)
Follow the steps below to pull the SDK from the “maven” repository
- Open your project’s build.gradle, and update the “allprojects” block, as follows
allprojects { repositories { jcenter() maven { url "https://cdn01.static.adfalcon.com/sdk/android/maven" } } }
- Update the “dependencies” block of your module’s build.gradle file, as follows:
dependencies { implementation 'com.noqoush.adfalcon.android.sdk:adfalcon-sdk:5.2.0' }
Sync your project with Gradle files.
Adding AdFalcon SDK library using AAR file
- Download the AAR file
- Click File > New Module.
- Click Import .JAR/.AAR Package then click Next.
- Select the location of AdFalcon SDK AAR file then click Finish.
- Make sure the library “adfalcon-sdk-5.1.2” is listed at the top of your “settings.gradle” file, as follows:
include ':app', ':adfalcon-sdk-5.2.0'
- Open the app module’s “build.gradle” file and add a new line to the “dependencies” block, as follows:
dependencies { implementation project( ': adfalcon-sdk-5.2.0 ') }
- Sync your project with Gradle files.
For more information please refer to https://developer.android.com/studio/projects/android-library.html#AddDependency
Configure Network Security Policy
Starting with Android 9 (API level 28), cleartext support is disabled by default. while the ads contain non encrypted resources such as images, videos, javascript files and etc. due to that the cleartext support should be enabled to draw the ads without any problem.
to enable the cleartext (HTTP Request) open the manifest of the app, then add the attribute of android:usesCleartextTraffic=”true” to the application element as following
<application android:usesCleartextTraffic="true"
for more information please visit the references below
https://developer.android.com/guide/topics/manifest/application-element#usesCleartextTraffic
https://developer.android.com/training/articles/security-config
Configure Manifest
The instructions in this document assume that you are using Android Studio and Gradle. All the required AndroidManifest.xml entries (permissions and activities) for the SDK will be added to your app automatically.
1. Configure Application Permissions (Optional)
The Required permissions were added to the AndroidManifest.xml of the SDK, so no need to add them again.
The below permissions are optional but recommended.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.READ_CALENDAR" /> <uses-permission android:name="android.permission.WRITE_CALENDAR" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Note: To enable any of the permission(s) above in Android API level 23 (Marshmallow) and above, you must ask the user to grant the permission.
For more information about how to request the permissions, please refer to https://developer.android.com/training/permissions/requesting.html#perm-request
2. Configure Orientation Changes Handling
It is highly recommended to prevent the system from restarting your activity when the screen orientation changes. Add the below attribute to your activity tag:
android:configChanges= "keyboard|keyboardHidden|orientation|uiMode|screenLayout|screenSize|smallestScreenSize"
For more information please refer to http://developer.android.com/guide/topics/resources/runtime-changes.html
3. Hardware Acceleration
AdFalcon network supports HTML 5 video ads which requires enabling hardware acceleration.
We recommend that the developer enables hardware acceleration in their application by adding the below property to application tag or to each activity that contains AdFalcon banner.
android:hardwareAccelerated="true"
4. Adding Google Play Services
The terms and conditions of Google Play require using the Advertising ID to identify and track a user. The Advertising Id is included in Google Play services library, so you must add Google Play services library to your application to integrate with AdFalcon Android SDK.
Visit the below link for instruction on how to add Google play services library:http://developer.android.com/google/play-services/setup.html
Configure Proguard
To safely use Proguard with AdFalcon SDK, Google Mobile Ads and AdFalcon Mediation Adapter, add the following to your Proguard config:
-keep class com.noqoush.adfalcon.android.sdk.** {*;} -keep class com.google.ads.mediation.adfalcon.** {*;} -keep public class com.google.android.gms.ads.** { public *; } -keep public class com.google.ads.** { public *; }
Enabling Test Mode
During development, you can enable test mode and display test ads that will mimic real ads in terms of placement, behavior and events. To do so, you need to enable test mode by following the below steps:
- Complete the steps mentioned in the following help topics to add our components including the code to request ads.
- Run your app in debug to request your first ad.
- Check the debug console which should contain a message as follows:
**** AdFalcon: Use ADFTargetingParams to receive test ads **** ADFTargetingParams params = new ADFTargetingParams(); params.addTestDevice………….
- Modify your code to use the above code.
Note: This will enable test mode for only the device which you used in step 2-3.
Read More
Banner Ads
Interstitial Ads
Native Ads
Appendix A
Appendix B