1
我正在開發和Android應用程序需要顯示Facebook橫幅廣告,因爲我已成功生成Placement id並實施了Facebook開發人員網站建議的代碼。但問題是廣告沒有顯示。在調試我發現這個沒有填充錯誤。我在谷歌搜索這個錯誤,但無法解決它。任何幫助將不勝感激。這裏是我的代碼:Facebook廣告未顯示android
AdView adView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Instantiate an AdView view
adView = new AdView(this, PLACEMENT_ID, AdSize.BANNER_HEIGHT_50);
// Find the main layout of your activity
LinearLayout layout = (LinearLayout)findViewById(R.id.activityLayout);
// Add the ad view to your activity layout
layout.addView(adView);
adView.setAdListener(new AdListener() {
@Override
public void onError(Ad ad, AdError error) {
// Ad failed to load.
// Add code to hide the ad's view
}
@Override
public void onAdLoaded(Ad ad) {
// Ad was loaded
// Add code to show the ad's view
}
@Override
public void onAdClicked(Ad ad) {
// Use this function to detect when an ad was clicked.
}
});
// Request to load an ad
adView.loadAd();
}
可能在此處粘貼錯誤/堆棧跟蹤調試詳細信息,可以解決您的問題。 –