Sample project with example integration can be downloaded from:


Minimal Android version 4.1 (API level 16)

Include the SDK

You can download the latest NeftaPlugin module from:

Extract the NeftaPugin-release.aar file and include it in your Android project in /libs folder, so that it will look something like this:

Then include this module as a dependency in your project build.gradle:

implementation files('libs/NeftaPlugin-release.aar')


For the SDK to work it requires permissions for the network which you need to add to your project AndroidManifest.xml:

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />


To serve and track the ads for your app, you have to configure ad units in the dashboard. There you will get the application ID for the next step.

Code integration

You initialize the SDK with the following code:

import com.nefta.sdk.NeftaPlugin;

NeftaPlugin plugin = NeftaPlugin.Init(getApplicationContext(), "yourAppId");

Do this as soon as possible in the application startup, to ensure the accurate event recording. If you leave the appId parameter null or empty the SDK will run in demo mode. This means that it'll always show dummy ads. To test the native integration without dashboard configuration.

If you want just the events this is all that is needed. You can proceed to the implementation of the actual events:

Code integration - Ads

To start the ad logic and retrieve all the configuration (so that no resources are wasted in case you are not having ads or you don't want them straight away):

_plugin.PrepareRenderer(this); // activity in which the ads will be rendered

Since the SDK doesn't want to introduce its own lifecycle dependencies, you need to call OnResume and OnPause methods when the app goes or comes from the background:

  protected void onResume() {


  protected void onPause() {


To know and react to SDK behavior, you can subscribe to the following callbacks:

_plugin.OnReady = this::OnReady;
_plugin.OnBid = this::OnBid;
_plugin.OnLoadStart = this::OnStartLoad;
_plugin.OnLoadFail = this::OnLoadFail;
_plugin.OnLoad = this::OnLoad;
_plugin.OnBannerChange = this::OnBannerChange;
_plugin.OnShow = this::OnShow;
_plugin.OnClick = this::OnClick;
_plugin.OnReward = this::OnReward;
_plugin.OnClose = this::OnClose;


In case you have just one ad SDK or don't want to deal with header bidding you can skip this step.

The load function will bid and load an ad for you in the background.

You bid on a specific placement with this function:

// or

After which the OnBid callback will be fired with the price of the available ad or null if there is none. It is up to you to decide if you want to proceed and load this one, make another bid, go with an ad from another provider, or something else.

Loading and showing of an Ad

Before we can show an ad, we have to load it. We have two options for that. We can either load specific ad unit by its ID or type:

// or

After the ad loads the the OnLoad (or OnLoadFail) callback will be made. At that point IsReady function will start returning true:

// or

At this point, we can show the ad:

// or

Banner Ad Specifics

The easiest way to work with banners is to just toggle them on or off with the following function:

// or
_plugin.EnableBanner("4922960754245632", true);

With this, the SDK will take care of the constant loading and showing banner placement to maximize your earnings from this position.

Whenever the banner presentation changes (gets shown, hidden, or changes size) you will get a OnBannerChange callback with covered width and height in physical pixel size so you can correctly offset application visual elements if needed.

Video Ad Specifics

After watching the rewarded video placement till the end, the OnReward will get fired so you can reward the player.


Nefta SDK is not managing audio settings, it is all under your control. So you will probably want to pause or mute your own sounds when showing Interstitial or rewarded video. And then resume or unmute after returning from the fullscreen ad, for example:

_plugin.OnShow = this::OnShow;
_plugin.OnClose = this::OnClose;

private void OnShow(Placement placement, int width, int height) {
   if (placement._type == Placement.Types.Interstitial || placement._type == Placement.Types.RewardedVideo) {

private void OnClose(Placement placement) {
   if (placement._type == Placement.Types.Interstitial || placement._type == Placement.Types.RewardedVideo) {

Note that the ads are being rendered inside the Activity provided to PrepareRenderer. Therefore onPause and onResume won't be called when switching to and from Nefta Ads.

In case you want to set a custom identifier for the current player, which will be sent alongside BE calls:


You can verify the correct SDK behavior through logs: Testing