Skip to content

Instantly share code, notes, and snippets.

@Miouyouyou
Created December 9, 2015 23:58
Show Gist options
  • Save Miouyouyou/fbf2049295d068a43908 to your computer and use it in GitHub Desktop.
Save Miouyouyou/fbf2049295d068a43908 to your computer and use it in GitHub Desktop.
Mopub adapter used to load AppBrain adds
package your.wonderful.packagename;
/* First version : 2015-10-10
That's quick and very dirty way to add AppBrain ads through MoPub.
Remember to add the appropriate rights in your local
AndroidManifest.xml
The rights are (inside <application>) :
<!-- AppBrain SDK -->
<activity
android:name="com.appbrain.AppBrainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|
screenLayout|uiMode|screenSize|
smallestScreenSize" />
<service android:name="com.appbrain.AppBrainService" />
<receiver
android:name="com.appbrain.ReferrerReceiver"
android:exported="true" >
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
*/
import android.content.Context;
import android.view.View;
import com.appbrain.AppBrain;
import com.appbrain.AppBrainBanner;
import com.mopub.common.util.Views;
import com.mopub.mobileads.CustomEventBanner;
import java.util.Map;
public class MopubBrain extends CustomEventBanner {
// Add private member variable of type ADFView
View ad;
CustomEventBannerListener mBannerListener;
@Override
protected void loadBanner(final Context context,
final CustomEventBannerListener customEventBannerListener,
final Map<String, Object> localExtras,
final Map<String, String> serverExtras) {
mBannerListener = customEventBannerListener;
try {
AppBrain.addTestDevice("48a1a0af307ff524");
AppBrain.init(context);
ad = new AppBrainBanner(context);
/* The AppBrain BannerListener never worked
so we load the add directly */
mBannerListener.onBannerLoaded(ad);
} catch (Exception ex) {}
}
@Override
protected void onInvalidate() { Views.removeFromParent(ad); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment