|
HTML HTML5 HTMLタグ スマートフォン |
CSS CSSプロパティ CSS・HTML便利ツール |
HTML色見本 配色組み合わせツール 特殊文字 |
JAVA Android |
PHP Smarty修飾子 EXCEL |
*このページは web-dou.com のアーカイブです。(2025年 サイト統合)
AdMobへの登録が完了したらログインして、次に「アプリケーションの登録」を行います。
開発していないアプリケーションも登録できますのでその場合はアプリケーション名を「test」などで登録しておきましょう。
登録したアプリケーションを一覧から選択し、「設定を管理」をクリックします。
パブリッシャーIDを確認できます。
Google AdMob Ads SDK Downloads から GoogleAdMobAdsSdkAndroid.zip(2012年7月現在) をダウンロードし解凍します。
プロジェクト名を右クリック→ビルド・パス→外部アーカイブの追加
GoogleAdMobAdsSdk~.jar を選択します
プロジェクトの「参照ライブラリ」に追加されました。
ソース「 src/jp.mediawing.android.test/TestActivity.java 」
package jp.mediawing.android.test;
import java.util.ArrayList;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.os.Bundle;
import android.speech.RecognizerIntent;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.google.ads.*;
import com.adakoda.voicerecognitiontest.R.id;
public class Eigoreg2Activity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AdView adView = new AdView(this, AdSize.BANNER, "パブリッシャー ID" );
}
}
レイアウトファイル「 res/main.xml 」
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.ads.AdView android:id="@+id/adview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="パブリッシャーID"
ads:adSize="BANNER"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
ads:loadAdOnCreate="true" />
</LinearLayout>
マニフェストファイル「 AndroidManifest.xml 」
INTERNET、ACCESS_NETWORK_STATE の権限も追加して下さい。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="jp.mediawing.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".TestActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>