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 app as a reference project.
com.appodeal.ads.MrecView to your layout file:
SDK can't show ads without a network connection!
Appodeal.show() returns a boolean value indicating whether the show method call was passed to the appropriate SDK.
Display MREC In Programmatically Created View
Create banner view:
Check If Ad Is Loaded
Appodeal SDK allows you to tag each impression with different placement. To use placements, you need to create placements in Appodeal Dashboard. Read more about placements.
To show an ad with placement, you have to call show method like this in your activity:
If the loaded ad can’t be shown for a specific placement, nothing will be shown.
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 and its settings will be applied.
Placement settings affect ONLY ad presentation, not loading or caching.
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
Appodea.show() method if required.
This behavior can be changed by calling
Appodeal.setSharedAdsInstanceAcrossActivities(true)(See more: Enable Shared View Ads Instance Across Activities Logic)
If you want to hide the MREC from all activities and clear the memory, call the code below:
To disable automatic caching for MREC, use the code below before the SDK initialization:
Check If Ad Is Initialized
To check if MREC was initialized, you can use the method:
true, if the MREC was initialized.
Check If Autocache Is Enabled
To check if autocache is enabled for MREC, you can use the method:
true, if autocache is enabled for MREC.
Get Predicted eCPM
To get the predicted eCPM from the next block in the caching queue, use the method:
This method is reasonable to use if manual caching of ads is enabled.
Enable Shared View Ads Instance Across Activities Logic
Starting from SDK 2.8.1 Appodeal SDK binds the Banner/MREC to the Activity which was passed to the
To make it easier for you to manage View ads display logic across all Activities we added a new method in Appodeal class:
- When this method is used with the
trueparameter, 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
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. By default value is