build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
}
MainActivity.java
adView = new AdView(this);//new AdView(this);
adView.setAdUnitId("ca-app-pub-???????????????/5335932412");
adView.setAdSize(AdSize.SMART_BANNER);
layout = (RelativeLayout) findViewById(R.id.mainLayout);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
layout.addView(adView, params);
//39DDB5F0BC9A833F635156A14F3C
adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("39DDB255B5F0BC9A833F635156A14F3C").build();
adView.loadAd(adRequest);
adView.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
super.onAdLoaded();
Log.e("adView", "onLoad");
layout.setVisibility(View.VISIBLE);
}
});
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
'Android' 카테고리의 다른 글
네트워크 상태 실시간 체크 (0) | 2015.06.26 |
---|---|
상태바 error (you need to use a theme.appcompat theme (or descendant) with this activity) (0) | 2015.03.27 |
jni fatal signal (0) | 2015.02.18 |
페이스북 로그인 연동 (0) | 2015.02.04 |
andorid.mk 전체 빌드 (0) | 2015.01.30 |