本帖最后由 破晓 于 2015-1-26 22:45 编辑
AboutANEAdMob is an Adobe AIR native extension (ANE) for Android to show ads.
Supported functionality:
- show ad;
- cache interstitial ad;
- show interstitial ad;
- hide ad;
- listen tap, close, leave, etc. event.
DocsPlease, read docs and try ANE before asking any questions.
https://developers.google.com/mobile-ads-sdk/
http://help.adobe.com/en_US/air/extensions/index.html
InstallationExtension ID: com.pozirk.ads.AdMob
Add "AdMob.ane" and "air\AdMob\bin\AdMob.swc" to your AIR project.
Add the following lines to your AIR Aplication-app.xml file inside <manifestAdditions> section: - <a href="https://github.com/pozirk/ANEAdMob#installation" target="_blank">
- <uses-permission android:name="android.permission.INTERNET"/>
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
- <application>
- <meta-data android:name="com.google.android.gms.version" android:value="4323000" /> <!-- should be android:value="@integer/google_play_services_version" --> <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
- </application></a>
复制代码 Example- import com.pozirk.ads.admob.AdMob;
- import com.pozirk.ads.admob.AdParams;
- import com.pozirk.ads.admob.AdEvent;
- ...
- protected var _admob:AdMob = new AdMob();
- ...
- //> initialization of AdMob
- _admob.addEventListener(AdEvent.INIT_OK, onEvent);
- _admob.addEventListener(AdEvent.INIT_FAIL, onEvent);
- _admob.addEventListener(AdEvent.BANNER_SHOW_OK, onEvent);
- _admob.addEventListener(AdEvent.BANNER_SHOW_FAIL, onEvent);
- _admob.addEventListener(AdEvent.BANNER_LEFT_APP, onEvent);
- _admob.addEventListener(AdEvent.BANNER_OPENED, onEvent);
- _admob.addEventListener(AdEvent.BANNER_CLOSED, onEvent);
- _admob.addEventListener(AdEvent.INTERSTITIAL_SHOW_OK, onEvent);
- _admob.addEventListener(AdEvent.INTERSTITIAL_SHOW_FAIL, onEvent);
- _admob.addEventListener(AdEvent.INTERSTITIAL_CACHE_OK, onEvent);
- _admob.addEventListener(AdEvent.INTERSTITIAL_CACHE_FAIL, onEvent);
- _admob.addEventListener(AdEvent.INTERSTITIAL_LEFT_APP, onEvent);
- _admob.addEventListener(AdEvent.INTERSTITIAL_OPENED, onEvent);
- _admob.addEventListener(AdEvent.INTERSTITIAL_CLOSED, onEvent);
- _admob.init();
- ...
- protected function onEvent(ae:AdEvent):void
- {
- trace(ae.type+" "+ae._data);
- }
- //<
- //showing 468x60 ad at the bottom center side of the screen
- _admob.show("AD_UNIT_ID", AdParams.SIZE_IAB_BANNER, AdParams.HALIGN_CENTER, AdParams.VALIGN_BOTTOM);
- //hide ad
- _admob.hide();
- //caching and showing interstitial ad
- _admob.cacheInterstitial("AD_UNIT_ID");
- ...
- _admob.showInterstitial();
复制代码 Game with AdMobhttps://play.google.com/store/apps/details?id=air.com.pozirk.allinonemahjong2
In order to see the interstitial ad, you need to win/lose any game.
MiscANE is build with AIR13.0, in order to rebuild for another (lower only, no need to do this for higher) version, do the following:
- edit "air\extension.xml" and change 13.0, in very first line, to any version you need;
- edit "build.bat" and, in the very last line, change path from AIR13.0 SDK to any AIR SDK you need;
- execute "build.bat" to repack the ANE.
- pray, it works!

相关链接:
https://github.com/pozirk/ANEAdMob
|