Androidã«Admobåºåãè¨ç½®ããæ¹æ³
Andoridã¢ããªã®Admobã®åºåãå ¥ãã¦ã¿ãã®ã§ãã®æã®ã¡ã¢ã§ãã
ã¢ã«ã¦ã³ãç»é²
- Admobãéãã¦ãä»ããã¹ã¿ã¼ãããã¯ãªãã¯
- ã¢ã«ã¦ã³ãæ å ±ãç»é²ãã
- ã¡ã¼ã«ãéããã¦ããã®ã§ãªã³ã¯ãã¯ãªãã¯ããã¨ç»é²å®äº
ã¢ããªã®ç»é²
- ãã¼ã¸ä¸ã®ã¡ãã¥ã¼ããマーケットプレイスãéã
- ããµã¤ãåã³ã¢ããªã±ã¼ã·ã§ã³ãã¿ããé¸æ
- ããµã¤ã/ã¢ããªã±ã¼ã·ã§ã³ã®è¿½å ããã¯ãªãã¯
- ãAndroid ã¢ããªã±ã¼ã·ã§ã³ããã¯ãªãã¯
- ã¢ããªæ
å ±ãå
¥å
- æ£ç´ãããã®æ å ±ãã©ãã§ä½¿ãããã®ãåãããªãã詳細ã¯æ¥æ¬èªã§ããã®ããè±èªã§æ¸ãã¹ããªã®ãããã
- 次ã®ç»é¢ã§ãSDKã®ãã¦ã³ãã¼ãããã¯ãªãã¯ãã¦SDKããã¦ã³ãã¼ããã
SDKã使ã£ãåºåã®è¨å®æ¹æ³
READMEã¨ãµã³ãã«ã¢ããªãä»ãã¦ããããJavadocã«è¨å®æ¹æ³ãæ¸ãã¦ããã以ä¸ã¯ãã®è¨³ã
jarãã¡ã¤ã«ã®ã¤ã³ã¯ã«ã¼ã
- SDKã«å«ã¾ãã¦ããjarãã¡ã¤ã«ãAndroidããã¸ã§ã¯ãã®external libraryã«è¨å®ããã
- ããã¸ã§ã¯ãã®ã«ã¼ãç´ä¸ã«libsãã£ã¬ã¯ããªãä½æããadmob-sdk-android.jarãlibsã®ä¸ã«ã³ãã¼ãã
Eclipseã§ãã¹ãéã
- ããã¸ã§ã¯ãã®ããããã£ãéã(ããã±ã¼ã¸ã¨ã¯ã¹ããã¼ã©ã§å³ã¯ãªãã¯âããããã£)
- ããã«ãã"Java Build Path" ãé¸æ
- "Libraries" ã¿ããé¸æ
- "Add JARs..."ãã¯ãªãã¯
- libsã«ã³ãã¼ããjarãã¡ã¤ã«ãé¸æ
- "OK"ãã¯ãªãã¯
AndroidManifest.xml
AdMob publisher ID(ã¢ã«ã¦ã³ããä½æããã¨ãã«ä½ããããhttp://jp.admob.com/my_sites/ãã対象ã®ã¢ããªãã¯ãªãã¯ããã¨ç¢ºèªã§ãã)ãã¿ã°ã®ç´åã§è¨å®ããã
<!-- The application's publisher ID assigned by AdMob --> <meta-data android:value="ããã«IDãã³ãã" android:name="ADMOB_PUBLISHER_ID" /> </application>
ã¿ã°ã®ç´åã§ãã¼ããã·ã§ã³ã®è¨å®ããã
<!-- AdMob SDK permissions --> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> </manifest>
attrs.xml
AdViewã®ã¢ããªãã¥ã¼ã·ã§ã³è¨å®ããããã¡ã¤ã«ã"/res/values/attrs.xml"ããªããã°ä¸è¨ã®å
容ã§ä½æããã
ãã§ã«åå¨ããå ´åã¯declare-styleableã¨ã¬ã¡ã³ãã追å ããã
<?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable name="com.admob.android.ads.AdView"> <attr name="testing" format="boolean" /> <attr name="backgroundColor" format="color" /> <attr name="textColor" format="color" /> <attr name="keywords" format="string" /> <attr name="refreshInterval" format="integer" /> <attr name="isGoneWithoutAd" format="boolean" /> </declare-styleable> </resources>
Placing an AdView in a Layout
AdViewã¦ã£ã¸ã§ããã¯ã©ã®XML layoutã«ãè¨ç½®ãããã¨ãã§ããã
æåã®ã¹ãããã¯attrs.xmlãåç
§ããããã«ãAndroidManifest.xmlã«æ¸ããã¦ããããã±ã¼ã¸åãã¬ã¤ã¢ã¦ãã®xmlnsã«è¨è¿°ãããã¨ã
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:admobsdk="http://schemas.android.com/apk/res/com.admob.android.example" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <com.admob.android.ads.AdView android:id="@+id/ad" android:layout_width="fill_parent" android:layout_height="wrap_content" admobsdk:backgroundColor="#000000" admobsdk:textColor="#FFFFFF" admobsdk:keywords="Android application" /> </LinearLayout>
- AdViewã®æ¨ªå¹ ã¯ã¹ã¯ãªã¼ã³ãµã¤ãºã«ãã¹ãã§ãé«ãã¯å¸¸ã«48pixel.
Test Mode
ã¢ããªã±ã¼ã·ã§ã³ã«AdMobãå ¥ããããæåã¯ãã¹ãã¢ã¼ãã«ãããã¨ãæ¨å¥¨ããããã¹ãã¢ã¼ãã§ã¯ã常ã«åãåºåã表示ããããé常ã®åºåã¯ã¿ã¤ã ã¢ã¦ããªã©ãããã®ã§ãåä½ç¢ºèªã«ã¯åãã¦ãªãã
ãã¹ãã¢ã¼ãã§æå¾ éãã®è¡¨ç¤ºãã§ããããã¢ã¼ããoffã«ããããã¹ãã¢ã¼ã enableã§Android Marketã«ã¢ããªãããã¦ã¯ãããªãã