本文介绍了为什么我的机器人活动结束时,AdMob的加载广告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经把在其它方面的工作Android应用程序AdMob的广告,按照指示的。该应用程序有2个活动。其中之一是从第一只到达。我目前正在增加广告本次活动。我都试过创建一个 AD浏览报编程中的的onCreate 方法,添加适当的code到XML布局文件的活动。在这两种情况下,该活动将退出第二个活动,并深入第一,如果后退按钮已经尽快pssed $ P $,因为它(通过网络或至少某些广告数据)临危广告。如果我改变code,以便不使一个附加要求(即使我添加了广告的编程方式,但就是不叫 loadAd ),或者如果我关闭我的netwrok接入话,我看不到任何广告,但我的活动不退出无论是。这可能是造成这?

I've been putting AdMob ads in an otherwise working Android app, following the instructions here. The app has 2 activities. One of them is only reachable from the first. I'm currently adding ads to this second activity. I've tried both creating an AdView programmatically in the onCreate method and adding appropriate code to the XML layout file for the Activity. In both cases the activity will exit the second Activity and go to the first as if the back button had been pressed as soon as it recieves an ad (or at least some ad data over the network). If I change the code so as to not make an add request (even if I add the ad programatically but just don't to call loadAd), or if I turn off my netwrok access then I don't see any ads, but my Activity doesn't exit either. What could be causing this?

我已经通过所有的(我认为过时了)这里步骤 ,但这并不能帮助。只是要清楚的情况下,我做错了什么,我有:

I've gone through all the (I believe out of date) steps here, but that doesn't help. Just to be clear in case I did something wrong, I have:

  • Downloaded the latest Android and AdMob SDKs, at least as of last Friday.
  • Set 'target=android-17' in default.properties (which I had to create in the root of the project, since I couldn't fine) and project.properties (which is what I think the project actually uses).
  • Set 'android:minSdkVersion="3"' in AndroidManifest.xml.
  • Added the library to the project (by placing GoogleAdMobAdsSdk-6.2.1.jar in a libs directory in the project root).
  • Added a com.google.ads.AdActivity copied from here to AndroidManifest.xml.
  • Added permission to AndroidManifest.xml, again copied from the same place.
  • Copied both code and XML tags (and attributes) from here and added them to my project (replacing MY_AD_UNIT_ID with my publisher ID), although I also broke out the request in code to make the emulator a test device.
  • Added an attrs.xml with ad styles. I'm fairly certain this is obsolete advice, but I did it anyway. I used the one from this question, although I changed com.admob.android.ads.AdView to com.google.ads.

接下来的事情,我想你会想知道,如果你尽力帮助我的是什么LogCat中说。没有多少:

The next thing I think you'll want to know if you try to help me is what LogCat says. Not much:

09-02 14:33:34.861: I/Ads(12839): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"msid":"com.Package.Name","hl":"en","bas_off":0,"simulator":1,"preqs":0,"slotname":"a150cbaa53d9d3d","js":"afma-sdk-a-v6.2.1","isu":"B3EEABB8EE11C2BE770B684D95219ECB","u_audio":4,"cap":"m,a","cipa":0,"u_sd":1.5,"net":"ed","u_h":533,"oar":0,"session_id":"4834854664722735718","seq_num":"1","app_name":"1.android.com.Package.Name","bas_on":0,"kw":[],"u_w":320,"gnt":3,"adtest":"on","format":"320x50_mb","carrier":"310260","ad_pos":{"visible":0,"width":0,"height":0,"x":0,"y":0},"ptime":0});</script></head><body></body></html>
09-02 14:33:35.111: D/dalvikvm(12839): GC freed 8784 objects / 437720 bytes in 64ms
09-02 14:33:37.101: I/Ads(12839): Received ad url: <url: "http://googleads.g.doubleclick.net:80/mads/gma?msid=com.Package.Name&hl=en&bas_off=0&preqs=0&js=afma-sdk-a-v6.2.1&isu=B3EEABB8EE11C2BE770B684D95219ECB&u_audio=4&cap=m%2Ca&cipa=0&u_sd=1.5&net=ed&u_h=533&oar=0&session_id=4834854664722735718&seq_num=1&app_name=1.android.com.Package.Name&bas_on=0&kw&u_w=320&gnt=3&adtest=on&format=320x50_mb&carrier=310260&ptime=0&u_so=p&output=html&region=mobile_app&u_tz=0&client_sdk=1&ex=1&slotname=a14e8f77524dde8&kw_type=broad&gsb=3g&caps=interactiveVideo_th_autoplay_mediation_sdkAdmobApiForAds_di&jsv=41" type: "admob" afmaNotifyDt: "null" useWebViewLoadUrl: "false">
09-02 14:33:37.111: I/Ads(12839): Request scenario: Online server request.
09-02 14:33:38.061: I/jdwp(12861): received file descriptor 10 from ADB
09-02 14:33:38.091: D/ddm-heap(12861): Got feature list request

编辑:我不认为这将是非常有用的,但苏莱曼的请求汗这里是我当前的XML

I don't think it will be very useful, but at the request of suleman khan here is my current XML

<com.google.ads.AdView android:layout_width="wrap_content"
    android:layout_height="wrap_content" ads:adUnitId="a150cbaa53d9d3d"
    ads:adSize="SMART_BANNER" android:id="@+id/adView" ads:refreshInterval="60"
    ads:testDevices="TEST_EMULATOR"
    ads:loadAdOnCreate="true" />

我已经尝试过许多这样的变化,但没有成功。

I"ve tried many variations of this, with no success.

推荐答案

把这个code在你的XML:

Place this code in your xml:

<com.google.ads.AdView android:id="@+id/adView"
                         android:layout_width="wrap_content"
                         android:layout_alignParentTop="true"
                         android:layout_height="wrap_content"
                         ads:adUnitId="@string/my_publisher_id"
                         ads:adSize="SMART_BANNER"
                         ads:loadAdOnCreate="true"/>

希望你已经添加你的Publisher ID。

Hope you have added your publisher id.

这地方你的清单文件活动后:

Place this after your activity in Manifest file:

<activity android:name="com.google.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

正如你说,你已经在你的项目库添加​​JAR文件,也希望您会在您的构建路径配置吧。

As you said that you have added jar file in libs in your project and hope you have also configured it in your buildpath.

希望这有助于。

这篇关于为什么我的机器人活动结束时,AdMob的加载广告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 01:49