0

バナー広告が表示されない理由を教えてください。バナーが提供されていないかのように、ゲームと共に画面が表示されます。エラーは発生しません。

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);             
    RelativeLayout layout = new RelativeLayout(this);  

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

    View gameView = initializeForView(new GraphicsView(), false);
    AdView adView = new AdView(this, AdSize.BANNER, "a14fd65977f0c9f");
    adView.loadAd(new AdRequest());

    RelativeLayout.LayoutParams adParams = 
            new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, 
                            RelativeLayout.LayoutParams.WRAP_CONTENT);
    adParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    adParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

    layout.addView(gameView);
    layout.addView(adView, adParams);
    setContentView(layout);
}

アプリケーションが次の場合に書き込まれるログ:

06-16 00:24:38.359: W/webcore(1236): Can't get the viewWidth after the first layout
06-16 00:24:38.639: I/Ads(1236): Received ad url: <url: "http://googleads.g.doubleclick.net:80/mads/gma?preqs=0&session_id=6766832335174985152&u_sd=1&slotname=a14fd65977f0c9f&u_w=320&msid=ru.bk.sobaka.n.e.k&cap=m&js=afma-sdk-a-v6.0.1&mv=4002306.com.android.vending&isu=ECF7E913C428C1C5F97C257CF153F328&cipa=0&format=320x50_mb&net=ed&app_name=1.android.ru.bk.sobaka.n.e.k&hl=ru&u_h=480&carrier=25001&ptime=0&u_audio=1&u_so=p&output=html&region=mobile_app&u_tz=-240&ex=1&client_sdk=1&caps=interactiveVideo_clickTracking_sdkAdmobApiForAds&jsv=26" type: "admob" afmaNotifyDt: "null">
06-16 00:24:38.879: W/Ads(1236): IOException connecting to ad url.
06-16 00:24:38.879: W/Ads(1236): java.net.ConnectException: googleads.g.doubleclick.net/127.0.0.1:80 - Connection refused
06-16 00:24:38.879: W/Ads(1236):    at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:207)
06-16 00:24:38.879: W/Ads(1236):    at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:437)
06-16 00:24:38.879: W/Ads(1236):    at java.net.Socket.connect(Socket.java:983)
06-16 00:24:38.879: W/Ads(1236):    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:75)
06-16 00:24:38.879: W/Ads(1236):    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:48)
06-16 00:24:38.879: W/Ads(1236):    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:322)
06-16 00:24:38.879: W/Ads(1236):    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89)
06-16 00:24:38.879: W/Ads(1236):    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:285)
06-16 00:24:38.879: W/Ads(1236):    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:267)
06-16 00:24:38.879: W/Ads(1236):    at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:205)
06-16 00:24:38.879: W/Ads(1236):    at com.google.ads.internal.f.b(SourceFile:428)
06-16 00:24:38.879: W/Ads(1236):    at com.google.ads.internal.f.run(SourceFile:399)
06-16 00:24:38.879: W/Ads(1236):    at java.lang.Thread.run(Thread.java:1019)
4

1 に答える 1

0

Very Angry Robots で広告を表示したときに使用したコードを次に示します。ビューがレイアウトに追加されるまで、広告の読み込みを要求しませんでした。

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    goFullScreen();
    View gameView = createGameView();
    AdView adView = createAdView();
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    LayoutParams layoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    layout.addView(adView, layoutParams);
    layout.addView(gameView, layoutParams);
    setContentView(layout);
    startAdvertising(adView);
}

private AdView createAdView() {
    AdView adView = new AdView(this, AdSize.BANNER, PUBLISHER_ID);
    return adView;
}

private void startAdvertising(AdView adView) {
    AdRequest adRequest = new AdRequest();
    adRequest.addTestDevice(MY_PHONE);
    adView.loadAd(adRequest);
}
于 2012-06-15T06:53:58.667 に答える