您好我已经在手机和平板电脑中使用DFP广告管理系统广告单元ID。我可以在尺寸为smartBanner的横幅广告中看到手机中的广告,但我在平板电脑上看不到任何广告,而且我收到的消息只有“广告已完成加载”。
我为手机和平板电脑使用了两个不同的广告单元ID,广告尺寸也意味着我正在使用AdSize.SMART_BANNER for Phone和新的AdSize(Constants.getScreenWidhth(),50)用于平板电脑设备
我的代码部分是
adView = new PublisherAdView(this);
actvity = AlbumsListActivity.this;
// Find out the Device either Phone or Tablet
String deviceType = Constants.screenSizeFindOut(actvity);
String Tag = "AlbumsListActivity";
if(deviceType.equals("tablet")){
Log.i(Tag ,
"Google Admob Id for tablet: "
+ this.getResources().getString(
R.string.GoogleAdMob_TabletadUnitId));
adView.setAdUnitId(this.getResources().getString(
R.string.GoogleAdMob_TabletadUnitId));
adView.setAdSizes(new AdSize(Constants.getScreenWidhth(), 50));
}
else if(deviceType.equals("phone")){
Log.i(Tag,
"Google Admob Id for phone: "
+ this.getResources().getString(
R.string.GoogleAdMob_PhoneadUnitId));
adView.setAdUnitId(this.getResources().getString(
R.string.GoogleAdMob_PhoneadUnitId));
adView.setAdSizes(AdSize.SMART_BANNER);
}
else
;
public static String screenSizeFindOut(Activity mContext){
DisplayMetrics metrics = new DisplayMetrics();
mContext.getWindowManager().getDefaultDisplay().getMetrics(metrics);
widthPixels = metrics.widthPixels;
heightPixels = metrics.heightPixels;
Log.d("" + mContext.getLocalClassName(), "Width and Height of the screen :"+widthPixels+ "/" + heightPixels );
float scaleFactor = metrics.density;
float widthDp = widthPixels / scaleFactor;
float heightDp = heightPixels / scaleFactor;
float smallestWidth = Math.min(widthDp, heightDp);
if (smallestWidth > 720) {
//Device is a 10" tablet
return "tablet";
}
else if (smallestWidth > 600) {
//Device is a 7" tablet
return "tablet";
}
else
return "phone";
}
public static int getScreenWidhth(){
return widthPixels;
}
如果有人为此获得解决方案,请帮助我