在我之前的问题之后,我已经设法添加和广告横幅到我的应用程序,但当我在模拟器或手机中运行它时,在广告横幅中它说
"你必须在AndroidManifest.xml中使用configChanges声明AdActivity!
在我的清单中我有......
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"/>
Run Code Online (Sandbox Code Playgroud)
这是从下载的示例中复制的....
如果我按照Admob的说明......清单应该是这样的......
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
Run Code Online (Sandbox Code Playgroud)
清单有错误,不会保存..?它说不允许字符串类型?
下面是完整maifest的代码,这是有错误的代码...
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.coopersoft.ELcalcV"
android:versionCode="5"
android:versionName="1.1">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".ELcalcV"
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=".Help"
android:label="@string/help_title" >
</activity>
<activity android:name=".About"
android:label="@string/about_title"
android:theme="@android:style/Theme.Dialog">
</activity>
<activity android:name=".CalcV"
android:label="@string/calc_title">
</activity>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用AdWhirl和AdMob将广告整合到我的Android应用中.
AdWhirl网站给了我以下代码:
AdWhirlLayout adWhirlLayout = (AdWhirlLayout) findViewById(R.id.layoutAdWhirl);
int diWidth = 320;
int diHeight = 52;
int density = (int) getResources().getDisplayMetrics().density;
int scaledWidth = (int) (diWidth * density);
int scaledHeight = (int) (diHeight * density);
adWhirlLayout.setAdWhirlInterface(this);
adWhirlLayout.setMaxWidth(scaledWidth);
adWhirlLayout.setMaxHeight(scaledHeight);
Run Code Online (Sandbox Code Playgroud)
这在我的一些模拟器上运行得很好,但是当我尝试一些较小或较旧的模拟器时,我在LogCat中收到以下错误:
Not enough space to show ad! Wants: 480, 75, Has: 320, 52
Run Code Online (Sandbox Code Playgroud)
如果我使用他们的代码来请求尺寸合适的广告,我该怎么办,但他们不会展示该广告?
我已经使用了admob sdk并添加了外部jar.In xml我指定了
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/headerfield"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ListView android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="Publisher Id"
ads:loadAdOnCreate="true" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
表现
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"/>
Run Code Online (Sandbox Code Playgroud)
但在图形模式下它给我一个错误日志:
com.google.ads.AdView - the following class could not be instantiated.
Run Code Online (Sandbox Code Playgroud)
程序里面显示它
您必须在AndroidManifest.xml中使用configChanges声明AdActivity.