我实施了Adwhirl,但没有广告出现
下面是我在其中添加我的AdWhirl布局的线性布局的xml代码:
<LinearLayout
android:id="@+id/ll_ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
>
</LinearLayout>
下面是我创建Adwhril布局并将其添加到LinearLayout“ll_ad”的代码:
AdWhirlManager.setConfigExpireTimeout(1000 * 60 * 5);
AdWhirlTargeting.setAge(23);
AdWhirlTargeting.setGender(AdWhirlTargeting.Gender.MALE);
AdWhirlTargeting.setKeywords("online games gaming");
AdWhirlTargeting.setPostalCode("94123");
AdWhirlTargeting.setTestMode(false);
AdWhirlLayout adWhirlLayout = new AdWhirlLayout(this,
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
int diWidth = 320;
int diHeight = 52;
float density = getResources().getDisplayMetrics().density;
adWhirlLayout.setAdWhirlInterface(this);
adWhirlLayout.setMaxWidth((int) (diWidth * density));
adWhirlLayout.setMaxHeight((int) (diHeight * density));
layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
LinearLayout layout = (LinearLayout) findViewById(R.id.ll_ad);
layout.setGravity(Gravity.CENTER_HORIZONTAL);
layout.addView(adWhirlLayout, layoutParams);
layout.invalidate();
以下是logcat消息:
09-05 23:09:39.055: I/AdWhirl SDK(278): Creating adWhirlManager...
09-05 23:09:39.055: D/AdWhirl SDK(278): Locale is: en_US
09-05 23:09:39.105: D/AdWhirl SDK(278): Hashed device ID is: XXXXXXXXXXXXXXXXXXXXXXXXXXX
09-05 23:09:39.105: I/AdWhirl SDK(278): Finished creating adWhirlManager
09-05 23:09:39.154: D/AdWhirl SDK(278): Prefs{xxxxxxxxxxxxxxxxxxxxxxxx}: {"config": "{"extra":{"location_on":1,"background_color_rgb":{"red":255,"green":255,"blue":255,"alpha":1},"text_color_rgb":{"red":0,"green":0,"blue":0,"alpha":1},"cycle_time":30,"transition":8},"rations":[{"nid":"xxxxxxxxxxxxxxxxxxxxx","type":20,"nname":"zestadz","weight":50,"priority":2,"key":"xxxxxxxxxxxxxxxxxxxxxxxx"},{"nid":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","type":1,"nname":"admob","weight":50,"priority":1,"key":"xxxxxxxxxxxxxxxxxxxxxx"}]}
09-05 23:09:39.154: D/AdWhirl SDK(278): ", "timestamp": 1346886053654}
09-05 23:09:39.164: I/AdWhirl SDK(278): Stored config info not present or expired, fetching fresh data
09-05 23:09:39.284: D/AdWhirl SDK(278): HTTP/1.1 200 OK
09-05 23:09:39.304: D/AdWhirl SDK(278): Received jsonString: {"extra":{"location_on":1,"background_color_rgb":{"red":255,"green":255,"blue":255,"alpha":1},"text_color_rgb":{"red":0,"green":0,"blue":0,"alpha":1},"cycle_time":30,"transition":8},"rations":[{"nid":"xxxxxxxxxxxxxxxxxxxxxxxx","type":20,"nname":"zestadz","weight":50,"priority":2,"key":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"},{"nid":"xxxxxxxxxxxxxxxxxxxxxxxxx","type":1,"nname":"admob","weight":50,"priority":1,"key":"xxxxxxxxxxxxxxxxxxxx"}]}
09-05 23:09:39.374: I/AdWhirl SDK(278): Rotating Ad
09-05 23:09:39.384: D/AdWhirl SDK(278): Dart is <11.333519576064566> of <100.0>
09-05 23:09:39.384: D/AdWhirl SDK(278): Showing ad:
09-05 23:09:39.384: D/AdWhirl SDK(278): nid: xxxxxxxxxxxxxxxxxxxxx
09-05 23:09:39.384: D/AdWhirl SDK(278): name: admob
09-05 23:09:39.384: D/AdWhirl SDK(278): type: 1
09-05 23:09:39.384: D/AdWhirl SDK(278): key: xxxxxxxxxxxxxxxxxxxx
09-05 23:09:39.384: D/AdWhirl SDK(278): key2:
09-05 23:09:39.384: D/AdWhirl SDK(278): Valid adapter, calling handle()
09-05 23:09:39.584: D/dalvikvm(278): GC_FOR_MALLOC freed 2017 objects / 531040 bytes in 159ms
09-05 23:09:39.594: E/Ads(278): The android:configChanges value of the com.google.ads.AdActivity must include screenLayout.
09-05 23:09:39.594: E/Ads(278): The android:configChanges value of the com.google.ads.AdActivity must include uiMode.
09-05 23:09:39.594: E/Ads(278): The android:configChanges value of the com.google.ads.AdActivity must include screenSize.
09-05 23:09:39.594: E/Ads(278): The android:configChanges value of the com.google.ads.AdActivity must include smallestScreenSize.
09-05 23:09:39.594: E/Ads(278): You must have AdActivity declared in AndroidManifest.xml with configChanges.
我已经在我的AndroidManifest中声明了AdActivity,但它仍然在LogCat中显示为警告。我还尝试在configChanges中添加uiMode,screenSize等,但它给了我错误。以下代码显示了Android Manifest中AdActivity的decalration :
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
谢谢!!
答案 0 :(得分:0)
每AdMob's documentation,您需要包含其他configChanges。清单中的AdActivity应如下所示:
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
您还应该考虑使用AdMob Mediation代替AdWhirl。 AdMob Mediation得到更好的支持,并且应该将更多广告网络集成到其中。