안드로이드 개발 질문/답변
(글 수 45,052)
안녕하세요.
admob 한번 달아보려는데 어렵네요 ㅠ.ㅠ
액티비티에서 이렇게 호출을 합니다.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.clock);
FrameLayout frame = (FrameLayout) findViewById(R.id.clockframe);
frame.addView(new ClockView(this));
}
------------------------------------------------------------------------------------
clock.xml이구요
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/clockframe"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.ads.AdView android:id="@+id/AdMobView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adUnitId="a14e0972"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"
android:layout_gravity="bottom"
/>
</FrameLayout>
그럼 이렇게 로그가 찍히고선 광고가 나오질 않습니다.
06-28 14:45:42.831: DEBUG/AndroidRuntime(1319): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
06-28 14:45:42.831: DEBUG/AndroidRuntime(1319): CheckJNI is ON
06-28 14:45:43.982: DEBUG/AndroidRuntime(1319): Calling main entry com.android.commands.am.Am
06-28 14:45:44.051: INFO/ActivityManager(61): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=net.rtong.android.jjapp/.JjAppMainActivity } from pid 1319
06-28 14:45:44.302: DEBUG/AndroidRuntime(1319): Shutting down VM
06-28 14:45:44.372: INFO/ActivityManager(61): Start proc net.rtong.android.jjapp for activity net.rtong.android.jjapp/.JjAppMainActivity: pid=1328 uid=10034 gids={3003}
06-28 14:45:44.391: INFO/AndroidRuntime(1319): NOTE: attach of thread 'Binder Thread #3' failed
06-28 14:45:44.461: DEBUG/dalvikvm(1319): GC_CONCURRENT freed 102K, 69% free 320K/1024K, external 0K/0K, paused 2ms+2ms
06-28 14:45:44.461: DEBUG/jdwp(1319): Got wake-up signal, bailing out of select
06-28 14:45:44.461: DEBUG/dalvikvm(1319): Debugger has detached; object registry had 1 entries
06-28 14:45:46.241: INFO/ActivityManager(61): Starting: Intent { cmp=net.rtong.android.jjapp/.clock.ClockActivity } from pid 1328
06-28 14:45:48.323: DEBUG/dalvikvm(1328): GC_EXTERNAL_ALLOC freed 93K, 52% free 2629K/5379K, external 2002K/2137K, paused 78ms
06-28 14:45:48.752: INFO/Ads(1328): To get test ads on this device, call adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
06-28 14:45:48.891: INFO/ActivityManager(61): Displayed net.rtong.android.jjapp/.clock.ClockActivity: +2s526ms (total +4s604ms)
06-28 14:45:50.921: INFO/Ads(1328): adRequestUrlHtml: <html><head><script src="http://www.gstatic.com/afma/sdk-core-v40.js"></script><script>AFMA_buildAdURL("{"preqs":0,"u_sd":1.5,"slotname":"a14e097252340d2","u_w":320,"msid":"net.rtong.android.jjapp","simulator":1,"cap":"m,a","js":"afma-sdk-a-v4.1.0","isu":"B3EEABB8EE11C2BE770B684D95219ECB","format":"320x50_mb","net":"ed","app_name":"1.android.net.rtong.android.jjapp","hl":"en","u_h":533,"u_audio":4,"u_so":"p"});</script></head><body></body></html>
06-28 14:45:52.642: INFO/Ads(1328): Received ad url: <"url": "http://r.admob.com:80/ad_source.php?preqs=0&u_sd=1.5&slotname=a14e097252340d2&u_w=320&msid=net.rtong.android.jjapp&cap=m%2Ca&js=afma-sdk-a-v4.1.0&isu=B3EEABB8EE11C2BE770B684D95219ECB&format=320x50_mb&net=ed&app_name=1.android.net.rtong.android.jjapp&hl=en&u_h=533&u_audio=4&u_so=p&output=html®ion=mobile_app&u_tz=0&ex=1&client_sdk=1", "afmaNotifyDt": "null">
06-28 14:45:53.171: DEBUG/webviewglue(1328): nativeDestroy view: 0x32d678
06-28 14:45:53.171: INFO/Ads(1328): onFailedToReceiveAd(Ad request successful, but no ad returned due to lack of ad inventory.)
06-28 14:45:54.103: DEBUG/dalvikvm(127): GC_EXPLICIT freed 25K, 49% free 3011K/5895K, external 4672K/5759K, paused 59ms
06-28 14:45:59.223: DEBUG/dalvikvm(316): GC_EXPLICIT freed 2K, 54% free 2538K/5511K, external 1625K/2137K, paused 120ms
06-28 14:46:05.191: DEBUG/dalvikvm(262): GC_EXPLICIT freed 9K, 55% free 2597K/5703K, external 1625K/2137K, paused 61ms
06-28 14:46:10.303: DEBUG/dalvikvm(304): GC_EXPLICIT freed 6K, 54% free 2544K/5511K, external 1625K/2137K, paused 125ms
06-28 14:47:10.182: DEBUG/SntpClient(61): request time failed: java.net.SocketException: Address family not supported by protocol
근데---------------------------------
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AdView ad = new AdView(this, AdSize.BANNER, AppInfo.AdMobPublisherID);
FrameLayout frame = new FrameLayout(this);
setContentView(frame);
frame.addView(new ClockView(this));
frame.addView(ad);
AdRequest request = new AdRequest();
request.setTesting(true);
ad.loadAd(request);
}
요렇게 호출하면 광고가 찍히긴하는데.... 앱이랑 겹쳐지더라구요.
ClockView가 canvas라서 하단에 찍고 싶은데 그게 안되네요 ㅠ.ㅠ
정리하자면...
처음 방식대로 하면 광고가 안 나옵니다. 애드몹 자리에 버튼을 넣어보면 버튼이 정상적으로 나옵니다.
두번째 방식으로 하면 광고 위치를 아래로 끌어내리질 못하겠습니다 ㅠ.ㅠ
첫번째 방식이 더 깔끔해보이는데... 방법 좀 알려주세요.
혹시 마켓에 등록이 안되어 있으면 안되나요? ㅡㅡ''''




혹시 첫번째 방식에서 admob을 ClockView가 덮어버리는거 아닌가요?
FrameLayout에서는 밑으로 내릴 수 없을꺼구요. RelativeLayout을 사용하세요.
ClockView가 어떤 코드인지 모르겠지만 Layout에서 잡아주면 더 좋을 것 같네요.
<RelativeLayout>
<Admob layout_alignParentBottom="true"/>
<ClockView layout_above="@id/ad"/>
</RelativeLayout>
모 이런식으로요.