标签: admob

Admob显示在标签布局中的列表视图

我有一个TabLayout,其中有一个ListView显示为intent.我想在这个布局中放置一个admob横幅,但它覆盖了ListActivity,覆盖了之前定义的列表的最后一项.我怎样才能使这个工作?

现在发布main.xml:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="top"
    android:orientation="vertical"
    android:padding="5dp" >

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp" >

    </FrameLayout>

</LinearLayout>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:gravity="bottom" >

<com.google.ads.AdView
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"

            ads:adSize="BANNER"
            ads:adUnitId="a14f67193b8a3e1"
            ads:loadAdOnCreate="true"
            ads:testDevices="TEST_EMULATOR, 3433B134225900EC" >

        </com.google.ads.AdView>
 </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

layout android admob

1
推荐指数
1
解决办法
1957
查看次数

我可以在Android布局中添加几个广告横幅?

我想在LinearLayout中添加第二个广告横幅,但是插入第二个横幅时我的应用程序崩溃。将外部横幅插入RelativeLayout效果很好,但是我想在ScrollView内添加第二个。我该怎么办?这是我的代码:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000" > 

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

          <TextView

          />

          <ToggleButton

          />

    <com.google.ads.AdView
    android:id="@+id/adView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"

    ads:adSize="BANNER"
    ads:adUnitId="xxxxxxxx"
    ads:loadAdOnCreate="true"
     >
</com.google.ads.AdView>

 </LinearLayout>
  </ScrollView>

 <com.google.ads.AdView
    android:id="@+id/adView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    ads:adSize="BANNER"
    ads:adUnitId="xxxxxxxxx"
    ads:loadAdOnCreate="true"
     >
</com.google.ads.AdView>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

android ads banner admob android-linearlayout

1
推荐指数
1
解决办法
3239
查看次数

广告已加载时调用loadAd,因此中止

我正在使用adMob,在我的模拟器上进行测试 ads:adUnitId

当我运行我的应用程序时,广告加载得很好,但我一直在我的logcat中收到此消息.

广告已加载时调用loadAd,因此中止

这是我的onCreate方法中的代码:

AdView adView = (AdView)this.findViewById(R.id.adView);
        AdRequest adResquest = new AdRequest();
        adResquest.addTestDevice("blablablablabla");
        adView.loadAd(adResquest);
Run Code Online (Sandbox Code Playgroud)

这是我的xml文件:

<com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="a14d7f7d2180609"
        ads:loadAdOnCreate="true"
        ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" />
Run Code Online (Sandbox Code Playgroud)

android admob android-logcat

1
推荐指数
1
解决办法
1808
查看次数

对象C两个代理具有相同的函数名称:方​​法'interstitialDidReceiveAd:'的重复声明

GADInterstitialDelegate和IMInterstitialDelegate具有相同的函数名称: interstitialDidReceiveAd

//inmob
- (void)interstitialDidReceiveAd:(IMInterstitial *)ad
                        //callback:(id<IMInterstitialDelegate>)callback
{
    [ad presentInterstitialAnimated:YES];
      NSLog(@"!!! inmob interstitialDidReceiveAd ok ");
}

// Sent when an interstitial ad request failed
- (void)interstitial:(IMInterstitial *)ad didFailToReceiveAdWithError:(IMError *)error
            //callback:(id<IMInterstitialDelegate>)callback
{
        NSLog(@"!!! inmob didFailToReceiveAdWithError ");
   // NSString *errorMessage = [NSString stringWithFormat:@"Loading ad (%@) failed. Error code: %d, message: //%@", [self.detailItem objectForKey:@"title"], [error code], [error localizedDescription]];
    //NSLog(@"%@", errorMessage);
}

//admob
- (void)interstitialDidReceiveAd:(GADInterstitial *)interstitialAdmob
{
    NSLog(@"!!! admob interstitialDidReceiveAd ok");
}

- (void)interstitial:(GADInterstitial *)interstitial
            //callback:(id<GADInterstitialDelegate>)callback
didFailToReceiveAdWithError:(GADRequestError *)error
{
    NSLog(@"!!!!!!! admob interstitial error!");
} …
Run Code Online (Sandbox Code Playgroud)

objective-c admob inmobi

1
推荐指数
1
解决办法
432
查看次数

以编程方式调用adView时出错?

我是以编程方式在我的应用中调用Admob广告.首先,我宣布进口

import com.google.android.gms.ads.AdRequest
import com.google.android.gms.ads.AdSize
import com.google.android.gms.ads.AdView
Run Code Online (Sandbox Code Playgroud)

然后将我的adid定义为字符串

String my_ad_unit_id="*some number*";
Run Code Online (Sandbox Code Playgroud)

将广告称为 -

this.adView=new AdView (this,AdSize.BANNER,this.my_ad_unit_id);
((LinearLayout) this.findViewById(R.id.main)).addView(this.adView);
this.adView.loadAd(new AdRequest());
Run Code Online (Sandbox Code Playgroud)

仅在呼叫部分中存在错误.错误是 -

  • adView无法解析部分
  • AdView中的AdView()无法应用于:
  • AdRequest'(com.google.android.gms.ads.AdRequest.Builder)'在'com.google.android.gms.ads.AdRequest'中拥有私人访问权限

android admob

1
推荐指数
1
解决办法
1745
查看次数

插页式Admob不起作用:未定义AFMA_ReceiveMessage

我有两种广告:横幅广告和插页式广告.第一个效果非常好,但是当我按下后退按钮时我想要显示插页式广告(但我们不关心按钮),在关闭我的应用之前.但我的插页式广告不起作用,我的应用程序正在关闭日志中的此错误:

E/Ads(20984): JS: Uncaught ReferenceError: AFMA_ReceiveMessage is not defined (:1)
Run Code Online (Sandbox Code Playgroud)

我不知道这个错误意味着什么.我浏览了互联网,它可能来自我的互联网连接.我的Wifi?或者它可能来自Admob?

我应该尝试更好的联系吗?

谢谢你的帮助.

android ads interstitial admob

1
推荐指数
1
解决办法
5980
查看次数

如何仅在一个版本的应用中展示广告

我正在计划我的应用的广告与无广告版本.我已经设置了两个app风格.

在我的XML中,这个AdMob教程说我将其添加到我的活动XML中以保存横幅广告:

<com.google.android.gms.ads.AdView
        android:id="@+id/admob_adview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        ads:adSize="BANNER"
        ads:adUnitId="@string/banner_footer" />
Run Code Online (Sandbox Code Playgroud)

然后在代码中,教程说:

public class MainActivity extends AppCompatActivity {

    private AdView mAdMobAdView;
    Button button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mAdMobAdView = (AdView) findViewById(R.id.admob_adview);
        AdRequest adRequest = new AdRequest.Builder()
                .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                .addTestDevice("4DD0986B8BB49093161F4F00CF61B887")// Add your real device id here
                .build();
        mAdMobAdView.loadAd(adRequest);


        button = (Button) findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(getApplicationContext(), ActivityTwo.class));
            }
        });
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,如果我只希望这个广告在一种风格上与另一种风格显示,那么在不违反任何规则的情况下处理这种风格的正确方法是什么?通常会通过类似的方式检查口味

if (BuildConfig.FLAVOR.equals("adfree")) {
    //no ads
}
else …
Run Code Online (Sandbox Code Playgroud)

xml android ads admob android-productflavors

1
推荐指数
1
解决办法
536
查看次数

奖励广告回调未触发

我有一款游戏,当玩家丧生时,我希望他们能够再次观看视频。

我正在使用unity版本2018.1.1f1人,并且我已经下载了admob unity插件版本3.13.1

因此,如果玩家同意观看广告,则该广告将播放,然后继续游戏,而不会触发奖励玩家的回调。这是我的代码:

using System;
using UnityEngine;
using GoogleMobileAds.Api;
using UnityEngine.UI;

public class RewardAd : MonoBehaviour {
    private BannerView bannerView;
    private InterstitialAd interstitial;
    private RewardBasedVideoAd rewardBasedVideo;
    private float deltaTime = 0.0f;
    private static string outputMessage = string.Empty;

    public AudioSource musicPlayer;
    public Player player;

    public Text UIText;

    public static string OutputMessage
    {
        set { outputMessage = value; }
    }

    public void Start()
    {

        #if UNITY_ANDROID
        string appId = "ca-app-pub-3940256099942544~3347511713";
        #elif UNITY_IPHONE
        string appId = "ca-app-pub-3940256099942544~1458002511";
        #else
        string appId = "unexpected_platform"; …
Run Code Online (Sandbox Code Playgroud)

unity-game-engine admob

1
推荐指数
1
解决办法
1606
查看次数

无法导入com.google.android.gms:play-services-ads:17.1.1

apply plugin: 'com.android.application'
   android {
   compileSdkVersion 28

   defaultConfig {
      applicationId "com.kaiboon0216gmail.homeownerstarterkit"
      minSdkVersion 21
      targetSdkVersion 28
      versionCode 1
      versionName "1.0"
      testInstrumentationRunner 
      "android.support.test.runner.AndroidJUnitRunner"
    } 
    buildTypes {
       release {
          minifyEnabled false
          proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
       }
    }
}


dependencies {
   implementation fileTree(dir: 'libs', include: ['*.jar'])
   implementation 'com.android.support:appcompat-v7:28.0.0'
   implementation 'com.android.support.constraint:constraint-layout:1.1.3'
   testImplementation 'junit:junit:4.12'
   androidTestImplementation 'com.android.support.test:runner:1.0.2'
   androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
   implementation 'com.android.support:cardview-v7:28.0.0'
   implementation 'com.google.android.gms:play-services-ads:17.1.1'
}
Run Code Online (Sandbox Code Playgroud)

这些是我的代码。我正在使用Admob在我的应用中显示广告。当我添加以下代码时:“ 'com.google.android.gms:play-services-ads:17.1.1'”并同步我的应用崩溃。

之后,我转到Admob官方网站,发现此版本适用于'com.android.support:appcompat-v7:26.1.0'版本。但是,当我将compileSdkVersion更改为26时,我的应用仍然崩溃。

我已经测试了没有以下代码的代码:“ 'com.google.android.gms:play-services-ads:17.1.1'”并且它可以运行。我确定此代码是问题所在,但我不知道如何改正它。

谁能帮助解决我的问题?谢谢。

java android admob google-play-services

1
推荐指数
1
解决办法
7984
查看次数

AdMob广告在回收者视图中无法正确显示

我正在尝试在回收站视图中实施admob横幅广告,我想在每个被2整除的回收站视图项目之后显示横幅广告。为什么回收站视图项目没有显示在显示广告的特定位置上。

到目前为止,这是我所做的:

public class HomeBookAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{

private static final int LAYOUT_ADS= 0;
private static final int LAYOUT_BOOKS= 1;

private ArrayList<LoadHomeBooks> list;
private Context context;

AdRequest adRequest;

public HomeBookAdapter(ArrayList<LoadHomeBooks> list,Context context){

    this.list = list;
    this.context = context;
}

@Override
public int getItemViewType(int position) {

    if(!(position == 0) && position % 2 == 0){

        return LAYOUT_ADS;
    }else{

        return LAYOUT_BOOKS;
    }
}

@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

    View view =null;
    RecyclerView.ViewHolder viewHolder = null;

    if(viewType==LAYOUT_ADS)
    {
        view …
Run Code Online (Sandbox Code Playgroud)

android admob android-recyclerview

1
推荐指数
1
解决办法
142
查看次数