Close premium Android video ad

I am developing an application that includes an award-winning video before giving the player another life. For the convenience of users and participation, I want this rewarded video to be closed after 30 seconds, and the user will return to the application. We use a client-side intermediary solution for the 4 largest video networks (Chartboost, Vungle, App Lovin and Ad Colony).

Many ad networks provide similar functionality like MoPub MoPubView.destroy(). However, not all networks provide a programmatic method for closing their ads.

All the ad networks I've come across expand the class Viewto show their ads. This means that the ad itself must be on the application stack View.

Is there a way to loop through Viewsand close the one that matches the declaration? This seems to be possible since the MoPub SDK uses the following code:

public void destroy() {
    unregisterScreenStateBroadcastReceiver();
    removeAllViews();
    ....
}

And removeAllViews()- this is a ViewGroupmethod consisting of:

public void removeAllViews() {
    removeAllViewsInLayout();
    requestLayout();
    invalidate(true);
}

I don’t like combining this code ViewGroupwith an iterator View, as in Enumerate / Iterate all views in Activity? . Any thoughts?

+4
source share
1 answer

, 30 ? , XML-, XML- ID findViewById (...) .

+1

All Articles