实时广告显示在枚举器中而非设备中 [英] realtime ads displaying in enumulator and not in device
本文介绍了实时广告显示在枚举器中而非设备中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的Android应用程序中使用admob集成广告,并且它在枚举器中工作正常但不在我的实时设备中。
< pre lang = java>
//将AdView视为资源并加载请求。
AdView adView =(AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()。build();
adView.loadAd(adRequest);
但它还没有在实时设备上工作
<? xml version = 1.0 encoding = utf-8 ? >
< 清单 xmlns: android = http://schemas.android.com/apk/res/android
package = com.example.android_addmob_ads
android:versionCode = 1
android: versionName = 1.0 >
< uses-sdk
android:minSdkVersion = 8
android:targetSdkVersion = 19 / >
< uses-permission android:name = android.permission.INTERNET / >
< uses-permission android:name = android.permission.ACCESS_NETWORK_STATE / >
< application
android:allowBackup = true < span class =code-attribute>
< span class =code-attribute> android:icon = @ drawable / ic_launcher
android:label = @ string / app_name
android:theme = @ style / AppTheme >
< 元数据
< span class =code-attribute> android:name = com.google.android.gms.version
android:value = @ integer / google_play_services_version / >
< 活动 < span class =code-attribute>
< span class =code-attribute> android:name = 。MainActivity
android:label = @ string / app_name >
< intent-filter >
< action android:name = android。 intent.action.MAIN / >
< category android:name = android.intent.category.LAUNCHER / >
< / intent-filter >
< / activity >
< 活动
android:name = com.google.android.gms.ads.AdActivity
< span class =code-attribute> android:configChanges = keyboard | keyboardHidden | orientation | screenLayout | uiMode | screenSize | smallestScreenSize / > ;
< / application >
< / manifest >
< RelativeLayout xmlns:android = h ttp://schemas.android.com/apk/res/android
xmlns:tools = http://schemas.android.com/tools
< span class =code-attribute> xmlns:ads = http://schemas.android.com/apk/res-auto
android:layout_width = match_parent
android:layout_height = match_parent
android:paddingBottom = @ dimen / activity_vertical_margin
android:paddingLeft = @ dimen / activity_horizontal_margin
android:paddingRight = < span class =code-keyword> @ dimen / activity_horizontal_margin
andr oid:paddingTop = @ dimen / activity_vertical_margin
tools:context = com.example.android_addmob_ads.MainActivity >
< TextView
android:id = @ + id / textView1
android:layout_width = wrap_content
android:layout_height = wrap_content
android:text = @ string / hello_world / >
< com.google.android.gms.ads.AdView < span class =code-attribute> android:id = @ + id / adView
android:layout_width = < span class =code-keyword> wrap_content
< span class =code-attribute> android:layout_height = wrap_content
< span class =code-attribute> ads:adUnitId =
< span class =code-attribute> ads:adSize = BANNER / >
< / RelativeLayout >
i给广告单元ID
决方案
i integrated ads using admob in my android apps and its working fine in enumulator but not in my real time device.
<pre lang="java">
// Look up the AdView as a resource and load a request. AdView adView = (AdView)this.findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().build(); adView.loadAd(adRequest);
But still its not working in real time device
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android_addmob_ads"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>
</manifest>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.android_addmob_ads.MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<com.google.android.gms.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId=""
ads:adSize="BANNER"/>
</RelativeLayout>
i gave ad unit id also
解决方案
这篇关于实时广告显示在枚举器中而非设备中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文