2012-11-22 3 views
0

화면 하단에 배너가 표시됩니다. Relativelayout check banner ad?

는 XML 코드입니다 :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/layoutAdView" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="50dp" 
    android:layout_alignParentBottom="true" 
    android:gravity="center_horizontal" > 
</RelativeLayout> 

가 가끔 광고 요청이 완료 얻을,하지만 난 배너를 볼 수 없습니다.

어떻게 상대 레이아웃을 확인할 수 있습니까? 상대 레이아웃에 무언가가 표시되면 사실을 거짓으로 표시해야합니다.

+1

에는 태그를 레이아웃하지에이 태그를 사용 : http://meta.stackexchange.com/questions/19190/should-questions-include-tags-in- their-titles –

답변

1

사용중인 광고 서버 소프트웨어를 지정하지 않았으므로 Google Admob SDK를 사용한다고 가정합니다.

화면의 광고 공간에 AdListener를 연결하고 추가 표시가 실패 할 때 수행 할 작업을 처리 할 수 ​​있습니다.

import android.content.Context; 
import android.util.Log; 
import android.widget.Toast; 

import com.google.ads.Ad; 
import com.google.ads.AdListener; 
import com.google.ads.AdRequest; 
import com.google.ads.AdRequest.ErrorCode; 

public class AdmobAdListener implements AdListener { 

    Context context; 
    AdRequest adRequest; 

    public AdmobAdListener(Context context, AdRequest adRequest) { 
     this.context = context; 
     this.adRequest = adRequest; 
    } 

    /** The log tag. */ 
    private static final String LOG_TAG = "AdmobAdListener"; 

    /** Called when an ad is clicked and about to return to the application. */ 
    public void onDismissScreen(Ad arg0) { 
     Log.d(LOG_TAG, "onDismissScreen"); 
     Toast.makeText(context, "onDismissScreen", 
     Toast.LENGTH_SHORT).show(); 

    } 

    /** Called when an ad was not received. */ 
    public void onFailedToReceiveAd(Ad ad, ErrorCode error) { 
     String message = LOG_TAG + " onFailedToReceiveAd (" + error + ")"; 
     Log.d(LOG_TAG, message); 
     Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); 
     ad.loadAd(adRequest); 
    } 

    /** 
    * Called when an ad is clicked and going to start a new Activity that will 
    * leave the application (e.g. breaking out to the Browser or Maps 
    * application). 
    */ 
    public void onLeaveApplication(Ad ad) { 
     Log.d(LOG_TAG, "onLeaveApplication"); 
     Toast.makeText(context, "onLeaveApplication", Toast.LENGTH_SHORT).show(); 
    } 

    /** 
    * Called when an Activity is created in front of the app (e.g. an 
    * interstitial is shown, or an ad is clicked and launches a new Activity). 
    */ 
    public void onPresentScreen(Ad ad) { 
     Log.d(LOG_TAG, "onPresentScreen"); 
     Toast.makeText(context, "onPresentScreen", 
     Toast.LENGTH_SHORT).show(); 
    } 

    /** Called when an ad is received. */ 
    public void onReceiveAd(Ad ad) { 
     Log.d(LOG_TAG, "onReceiveAd"); 
     Toast.makeText(context, "onReceiveAd", Toast.LENGTH_SHORT).show(); 
    } 

} 

당신이 XML 파일을 주제에

<com.google.ads.AdView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:id="@+id/adMob" 
     ads:adUnitId="abcdefghighlmnop123" 
     ads:adSize="BANNER"/> 
+0

InMobi + AdMob을 사용하고 있습니다. AdMob은 훌륭합니다. 완벽하게 작동합니다. 질문은 InMobi에 대한 것이 었습니다. – user1205415