守望者--AIR技术交流

标题: AdMob 广告ANE(Android) [打印本页]

作者: 破晓    时间: 2015-1-26 22:39
标题: AdMob 广告ANE(Android)
本帖最后由 破晓 于 2015-1-26 22:45 编辑

About

ANEAdMob is an Adobe AIR native extension (ANE) for Android to show ads.
Supported functionality:

Docs

Please, 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

Installation

Extension 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:

  1. <a href="https://github.com/pozirk/ANEAdMob#installation" target="_blank">

  2. <uses-permission android:name="android.permission.INTERNET"/>
  3. <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  4. <application>
  5. <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"/>
  6. </application></a>
复制代码
Example
  1. import com.pozirk.ads.admob.AdMob;
  2. import com.pozirk.ads.admob.AdParams;
  3. import com.pozirk.ads.admob.AdEvent;

  4. ...

  5. protected var _admob:AdMob = new AdMob();

  6. ...

  7. //> initialization of AdMob
  8. _admob.addEventListener(AdEvent.INIT_OK, onEvent);
  9. _admob.addEventListener(AdEvent.INIT_FAIL, onEvent);
  10. _admob.addEventListener(AdEvent.BANNER_SHOW_OK, onEvent);
  11. _admob.addEventListener(AdEvent.BANNER_SHOW_FAIL, onEvent);
  12. _admob.addEventListener(AdEvent.BANNER_LEFT_APP, onEvent);
  13. _admob.addEventListener(AdEvent.BANNER_OPENED, onEvent);
  14. _admob.addEventListener(AdEvent.BANNER_CLOSED, onEvent);
  15. _admob.addEventListener(AdEvent.INTERSTITIAL_SHOW_OK, onEvent);
  16. _admob.addEventListener(AdEvent.INTERSTITIAL_SHOW_FAIL, onEvent);
  17. _admob.addEventListener(AdEvent.INTERSTITIAL_CACHE_OK, onEvent);
  18. _admob.addEventListener(AdEvent.INTERSTITIAL_CACHE_FAIL, onEvent);
  19. _admob.addEventListener(AdEvent.INTERSTITIAL_LEFT_APP, onEvent);
  20. _admob.addEventListener(AdEvent.INTERSTITIAL_OPENED, onEvent);
  21. _admob.addEventListener(AdEvent.INTERSTITIAL_CLOSED, onEvent);
  22. _admob.init();

  23. ...

  24. protected function onEvent(ae:AdEvent):void
  25. {
  26.     trace(ae.type+" "+ae._data);
  27. }
  28. //<


  29. //showing 468x60 ad at the bottom center side of the screen
  30. _admob.show("AD_UNIT_ID", AdParams.SIZE_IAB_BANNER, AdParams.HALIGN_CENTER, AdParams.VALIGN_BOTTOM);

  31. //hide ad
  32. _admob.hide();

  33. //caching and showing interstitial ad
  34. _admob.cacheInterstitial("AD_UNIT_ID");
  35. ...
  36. _admob.showInterstitial();
复制代码
Game with AdMob

https://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.

Misc

ANE is build with AIR13.0, in order to rebuild for another (lower only, no need to do this for higher) version, do the following:







[attach]696[/attach]



相关链接:


https://github.com/pozirk/ANEAdMob


作者: 破晓    时间: 2015-1-29 16:15
相关下载:

http://www.airmyth.com/thread-989-1-1.html




欢迎光临 守望者--AIR技术交流 (http://www.airmyth.com/)