Hi I have DFP Ad Unit Id that have been using for DFP Banner Ad in both Phone and Tablet. i can see the ad in phone at the banner ad with size of smartBanner but i could not see any ad in Tablet and i got message only like "Ad finished loading".
I have used two different Ad unit id for phone and tablet and Ad size also that mean i am using AdSize.SMART_BANNER for Phone and new AdSize(Constants.getScreenWidhth(), 50) for Tablet devices
My Code Part is
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;
}
Please help me if some one got solution for this
0 comments:
Post a Comment