Skip to main content
Version: 3.3.0-beta

MREC

MREC is 300x250 banner. This type can be useful if the application has a large free area for placing a banner in the interface.

You can use our demo MREC app as a reference project.

Demo App

Check If Ad Is Loaded

You can check if the ad has been loaded before showing it. This method returns a boolean value indicating whether or not the MREC has been loaded.

Appodeal.isLoaded(Appodeal.MREC)

We recommend you always check whether an ad is available before trying to show it.

if (Appodeal.isLoaded(Appodeal.MREC)) {
Appodeal.show(this, Appodeal.MREC)
}

Display

To display MREC, you need to call the following code in the activity:

  1. Add com.appodeal.ads.MrecView to your layout file:
<com.appodeal.ads.MrecView
android:id="@+id/appodealMrecView"
android:layout_width="300dp"
android:layout_height="250dp" />
  1. Set view id before the SDK initialization to show MREC:
Appodeal.setMrecViewId(R.id.appodealMrecView)
  1. Now you can show the MREC in the view specified (Make sure that the required view is on the screen):
Appodeal.show(this, Appodeal.MREC)

The method returns a boolean value indicating whether the call to the show method was passed to the appropriate SDK.

SDK can't show ads without a network connection!
MrecView should be on the top of the hierarchy and can not be overlapped by other views.

Manual Caching

By default, auto caching is enabled: Appodeal SDK starts to load MREC right after the initialization method is called.

The next MREC ad starts to load after the previous one has been closed.

To disable automatic caching for MREC, use the code below before SDK initialization:

Appodeal.setAutoCache(Appodeal.MREC, false)

To cache MREC use:

Appodeal.cache(this, Appodeal.MREC)

Read more on manual caching in our FAQ.

Display MREC In Programmatically Created View

  1. Create MREC view and add view to your layout:
val adView = Appodeal.getMrecView(this)
rootLayout.addView(adView)
  1. Now you can show the MrecView in the view specified (Make sure that the required view is on the screen):
Appodeal.show(this, Appodeal.MREC)

The method returns a boolean value indicating whether the call to the show method was passed to the appropriate SDK.

SDK can't show ads without a network connection!
MrecView should be on the top of the hierarchy and can not be overlapped by other views.

Callbacks

Appodeal.setMrecCallbacks(object : MrecCallbacks {
override fun onMrecLoaded(isPrecache: Boolean) {
// Called when MREC is loaded
}
override fun onMrecFailedToLoad() {
// Called when MREC failed to load
}
override fun onMrecShown() {
// Called when MREC is shown
}
override fun onMrecShowFailed() {
// Called when MREC show failed
}
override fun onMrecClicked() {
// Called when MREC is clicked
}
override fun onMrecExpired() {
// Called when MREC is expired
}
})
info

All callbacks are called on the main thread.

Placements

Appodeal SDK allows you to tag each impression with different placement. To be able to use placements, you need to create them in Appodeal Dashboard. Read more about placements.

Appodeal.show(this, Appodeal.MREC, "yourPlacementName")

If the loaded ad can't be shown in a specific placement, nothing will be shown. If auto caching is enabled, the SDK will start to cache another ad, which can affect display rate. To save the loaded ad for future use (for instance, for another placement), check if the ad can be shown before calling show method:

if (Appodeal.canShow(Appodeal.MREC, "yourPlacementName")) {
Appodeal.show(this, Appodeal.MREC, "yourPlacementName")
}

You can configure your impression logic for each placement.

If you have no placements or call Appodeal.show with a placement that does not exist, the impression will be tagged with default placement with corresponding settings applied.

Important!

Placement settings affect ONLY ad presentation, not loading or caching.

Check If Ad Is Initialized

To check if MREC was initialized, you can use the method:

Appodeal.isInitialized(Appodeal.MREC)

Returns true, if the MREC was initialized.

Check If Autocache Is Enabled

To check if autocache is enabled for MREC, you can use the method:

Appodeal.isAutoCacheEnabled(Appodeal.MREC)

Returns true, if autocache is enabled for MREC.

Get Predicted eCPM

This method returns the expected eCPM for the cached ad. The amount is calculated based on historical data for the current ad unit.

Appodeal.getPredictedEcpm(Appodeal.MREC)
This method is reasonable to use if manual caching of ads is enabled.

Activity "Paused" State Handling

We’ll automatically handle pause and resume state for already displayed MRECs on Activity on which they were displayed, however, we don’t restore displayed MRECs after Activity recreation (e.g. - orientation changes) and we don’t show MRECs in newly created Activities.

For display ads on newly created Activity just call Appodeal.show() method if required:

override fun onResume() {
super.onResume()
Appodeal.show(this, Appodeal.MREC)
}

This behavior can be changed by calling Appodeal.setSharedAdsInstanceAcrossActivities(true)

(See more: Enable Shared View Ads Instance Across Activities Logic)

Hide

Appodeal.hide(this, Appodeal.MREC)

Destroy

If you want to hide the MREC from all activities and clear the memory, call the code below:

Appodeal.destroy(Appodeal.MREC)

Enable Shared View Ads Instance Across Activities Logic

Appodeal SDK binds the Banner/MREC to the Activity which was passed to the Appodeal.show method.

To make it easier for you to manage View ads display logic across all Activities we added a new method in Appodeal class:

Appodeal.setSharedAdsInstanceAcrossActivities(sharedAdsInstanceAcrossActivities: Boolean)
  • When this method is used with the true parameter, the SDK will show AdView on all new activities without calling additional code from your side.
  • If you want to control the display yourself, you can call the method with the false parameter.
caution

In this case, this parameter is false, be careful with changing orientation or moving to a new activity, the Banner/MREC will not be shown automatically, since it was bound to the previous activity. If you want to hide the Banner/MREC, you need to call the Appodeal.hide() method with the parameters of the activity to which the Banner/MREC was bound.

You can also check the current state of this logic:

Appodeal.isSharedAdsInstanceAcrossActivities()
info

Shared View Ads Instance Across Activities is disabled by default

Check Viewability

You can always check in logs if show was tracked and your ad is visible.

You will see the Mrec [Notify Shown] log if show was tracked successfully.

Appodeal  com.example.app  D Mrec [Notify Shown]