gpt4 book ai didi

android - Admob 横幅广告无法在 Android 上正常运行

转载 作者:行者123 更新时间:2023-11-30 02:26:27 24 4
gpt4 key购买 nike

我在点击 ADMOB-BANNER ADS 时在 logcat 中收到消息

无法获取广告叠加信息

您好,我已经集成了 admob,并遵循它的 xml 代码

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<com.aviary.android.feather.library.services.drag.DragLayer
android:id="@+id/dragLayer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/adView" >

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/aviaryBackgroundColor"
android:orientation="vertical" >

<!-- main navbar ( title, apply and done buttons ) -->

<include
android:id="@+id/aviary_navbar"
layout="@layout/aviary_navbar" >
</include>

<!-- main content view -->

<RelativeLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/aviary_bottombar"
android:layout_below="@id/aviary_navbar"
android:padding="?attr/aviaryMainImagePadding" >

<!-- optional image view container -->

<RelativeLayout
android:id="@+id/drawing_view_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>

<!-- main image view -->

<com.aviary.android.feather.sdk.widget.AviaryImageViewUndoRedo
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible" />

<!-- main loader, visible while loading the image at start -->

<include
android:id="@+id/image_loading_view"
layout="@layout/aviary_main_loader" >
</include>
</RelativeLayout>

<!-- bottom bar (tools, panels) -->

<include
android:id="@+id/aviary_bottombar"
android:layout_width="match_parent"
android:layout_height="?attr/aviaryBottomBarHeight"
android:layout_alignParentBottom="true"
layout="@layout/aviary_bottombar" >
</include>

<!-- popup container dialog -->

<RelativeLayout
android:id="@+id/feather_dialogs_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/aviary_navbar"
android:visibility="invisible" >
</RelativeLayout>

<!-- hidden surface view -->

<SurfaceView
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="invisible" >
</SurfaceView>
</RelativeLayout>
</com.aviary.android.feather.library.services.drag.DragLayer>

<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/banner_ad_unit_id" >
</com.google.android.gms.ads.AdView>

</RelativeLayout>

Java代码

AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);

这是 list 文件

<application>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
</application>

但每当我点击横幅广告时,它都会显示点击响应但不会转移到 Play 商店或浏览器

最佳答案

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />

<!-- Creating AdView in XML and loading an ad -->

<com.google.android.gms.ads.AdView
android:layout_alignParentBottom="true"
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="(Here paste your google add key)" />

</RelativeLayout>

主 Activity .java

public class MainActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the view from activity_main.xml
setContentView(R.layout.activity_main);

AdView mAdView = (AdView) this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
// Add a test device to show Test Ads
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
mAdView.loadAd(adRequest);
}
}

AndroidManifest.xml

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

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.test.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>
<!-- Include the AdActivity configChanges and theme. -->
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
<!-- Google Play Service Meta-data Info -->
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>

关于android - Admob 横幅广告无法在 Android 上正常运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27873214/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com