2013-01-03 36 views
0

我測試應用程序時添加的應該是有一個框,表示將該活動添加到我的清單中,只要我添加了現在,那個盒子是。這裏是所有代碼放入我的應用程序我意識到現在有些是沒用的,因爲所有不同的事情我試過我的應用程序在不需要的代碼深處膝蓋深,如果你看到我可以刪除讓我知道的一切。AdMob廣告未向我的清單添加權限後未顯示

主要問題爲什麼廣告沒有出現

JAVA

AdView myAdView; 


    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.game_play); 


     myAdView=(AdView)findViewById(R.id.adView); 
     AdRequest adRequest = new AdRequest(); 
     adRequest.addTestDevice(AdRequest.TEST_EMULATOR); 
     myAdView.loadAd(adRequest); 

主要佈局

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/android_drinking"  
    tools:context=".PlayerInput" > 


    <com.google.ads.AdView 
      android:id="@+id/adView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      ads:adUnitId="a14ff402be4457c" 
      ads:adSize="BANNER" 
      ads:testDevices="TEST_EMULATOR" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true" 
      ads:loadAdOnCreate="true"/> 

ATTRS XML

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
<declare-styleable name="com.admob.android.ads.AdView"> 
<attr name="backgroundColor" format="color" /> 
<attr name="primaryTextColor" format="color" /> 
<attr name="secondaryTextColor" format="color" /> 
<attr name="keywords" format="string" /> 
<attr name="refreshInterval" format="integer" /> 
</declare-styleable> 
</resources> 

Android清單

<uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 

<meta-data android:value="YOUR_ID_HERE" android:name="ADMOB_PUBLISHER_ID" /> 
<!-- AdMobActivity definition --> 
<activity android:name="com.admob.android.ads.AdMobActivity" 
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 
android:configChanges="orientation|keyboard|keyboardHidden" /> 
<!-- Track Market installs --> 
<receiver android:name="com.admob.android.ads.analytics.InstallReceiver" 
android:exported="true"> 
<intent-filter> 
<action android:name="com.android.vending.INSTALL_REFERRER" /> 
</intent-filter> 
</receiver> 

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

    </application> 

    <uses-permission android:name="android.permission.INTERNET"/> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 

    </manifest> 

鏈接到我今晚想要的tutorial

回答

0

添加函數我通過電子郵件將應用程序發送給我自己將它安裝到我的wifes平板電腦上,並且他們的工作必須將其設置爲測試錯誤我也從應用程序中刪除了Java部分。

0

下面是一個簡單的教程,所有需要的信息

How to add Google ads in Android apps (Google Admob Ads

請記住在開發這個應用程序

  1. 您需要谷歌廣告發布者ID。
  2. 您需要添加谷歌AdMob廣告SDK.jar文件在你的類路徑
  3. 你必須有應用目標是API 13或更高版本
  4. 還PL不要忘記添加Internet權限
  5. 你需要加入谷歌廣告活動清單文件,應用標籤,這樣

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

希望它可以幫助你!

0

如果您正確地向admob發送請求,您可以檢查LogCat嗎?

有時候唯一的問題是,對於admob庫存不佳的請求失敗。