Have anyone tried integrating Airpush Banner ads to an Andengine activity? Can you pls share some codes?
Here is code I’m using to display airpush banners in andengine app:
manifest.xml permissions:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
manifest.xml declarations for banners:
<meta-data android:name="your_airpush_sdk_package_name.APPID" android:value="your_app_id" />
<meta-data android:name="your_airpush_sdk_package_name.APIKEY" android:value="android*your_apikey"/>
<activity android:exported="false" android:name="your_airpush_sdk_package_name.SmartWallActivity"
android:configChanges="orientation|screenSize"
android:theme="@android:style/Theme.Translucent" />
<activity android:name="your_airpush_sdk_package_name.BrowserActivity"
android:configChanges="orientation|screenSize" />
And implementation code. Just override onSetContentView method in your main andengine activity:
@Override
protected void onSetContentView() {
this.mRenderSurfaceView = new RenderSurfaceView(this);
this.mRenderSurfaceView.setRenderer(this.mEngine, this);
final android.widget.FrameLayout.LayoutParams surfaceViewLayoutParams =
new FrameLayout.LayoutParams(super.createSurfaceViewLayoutParams());
final FrameLayout frameLayout = new FrameLayout(this);
final FrameLayout.LayoutParams frameLayoutLayoutParams =
new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT,
FrameLayout.LayoutParams.FILL_PARENT);
final AdView airpushBanner = new AdView(
this, AdView.BANNER_TYPE_IN_APP_AD, AdView.PLACEMENT_TYPE_INTERSTITIAL,
45, false, false, AdView.ANIMATION_TYPE_LEFT_TO_RIGHT);
final FrameLayout.LayoutParams adViewLayoutParams =
new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT,
Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM);
frameLayout.addView(this.mRenderSurfaceView, surfaceViewLayoutParams);
frameLayout.addView(airpushBanner, adViewLayoutParams);
this.setContentView(frameLayout, frameLayoutLayoutParams);
}
}
@ByQ: thanks a lot!
@ByQ: Did your game stop when an “Ad loaded successfully” event fires? My game stops running when SDK refreshes (sometimes)
No, I didn’t notice anything like that
Did your game stop when an “Ad loaded successfully” event fires?