【问题标题】:Android + MoPub + PhoneGap (Cordova) Integration (Half working)Android + MoPub + PhoneGap (Cordova) 集成(一半工作)
【发布时间】:2013-08-11 19:42:59
【问题描述】:

过去,我已经按照这种模式(在主要活动中)使用 LinearLayout 小部件成功地将 AdMob 广告集成到我的 Android PhoneGap 应用中:

AdMob/PhoneGap 集成 - 有效 - 在 main.xml 中不需要额外的标记

public void onCreate(Bundle savedInstanceState)
{
  super.onCreate(savedInstanceState);
  super.loadUrl("file:///android_asset/www/index.html");
  adView = new AdView(this, AdSize.BANNER, AdMob_Ad_Unit); 
  LinearLayout layout = super.root;
  layout.addView(adView); 
  AdRequest request = new AdRequest();
  request.setTesting(true);
  adView.loadAd(request);
}

但是,我想使用 MoPub SDK 遵循类似的模式,我尝试了以下模式,然而,这并没有显示应用程序的 PhoneGap“webview”,尽管它正确加载了广告:

MoPub/PhoneGap 集成 - 广告有效,PhoneGap 无效 - 需要添加到 main.xml

public void onCreate(Bundle savedInstanceState)
{
  super.onCreate(savedInstanceState);
  super.loadUrl(Config.getStartUrl());
  setContentView(R.layout.main);
  moPubView = (MoPubView) findViewById(R.id.adview);
  moPubView.setAdUnitId(MOPUB_ID);
  moPubView.loadAd();
}

在main.xml中:

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
>
<com.mopub.mobileads.MoPubView
   android:id="@+id/adview"
   android:layout_width="fill_parent"
   android:layout_height="50dp"
/>

这就是显示的内容 - 我怎样才能让 PhoneGap 与 MoPub 一起工作?

【问题讨论】:

    标签: android android-layout cordova mopub


    【解决方案1】:

    解决了!以下是方法,希望对某人有所帮助:

    public void onCreate(Bundle savedInstanceState)
    {
      super.onCreate(savedInstanceState);
      super.loadUrl(Config.getStartUrl());
      LinearLayout layout = super.root;
      moPubView = new MoPubView(this);
      moPubView.setAdUnitId(MO_PUBID);
      moPubView.loadAd();
      layout.addView(moPubView);
    }
    

    【讨论】:

    • 你是如何在 iOS 上实现的
    猜你喜欢
    • 2013-12-06
    • 2013-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-16
    • 1970-01-01
    相关资源
    最近更新 更多