Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓&x2B;MoPub&x2B;PhoneGap(Cordova)集成(半工作)_Android_Android Layout_Cordova_Mopub - Fatal编程技术网

Android 安卓&x2B;MoPub&x2B;PhoneGap(Cordova)集成(半工作)

Android 安卓&x2B;MoPub&x2B;PhoneGap(Cordova)集成(半工作),android,android-layout,cordova,mopub,Android,Android Layout,Cordova,Mopub,过去,我使用LinearLayout小部件成功地将AdMob广告集成到我的Android PhoneGap应用程序中,遵循此模式(在主活动中): AdMob/PhoneGap集成-Works-不需要在main.xml中添加额外的标记 public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.loadUrl("file:///android_asset/www/in

过去,我使用LinearLayout小部件成功地将AdMob广告集成到我的Android PhoneGap应用程序中,遵循此模式(在主活动中):

AdMob/PhoneGap集成-Works-不需要在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);
}
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();
}
但是,我想使用MoPub SDK遵循类似的模式,我尝试了以下模式,但是,这并没有显示应用程序的PhoneGap“webview”,尽管它正确加载了广告:

MoPub/PhoneGap集成-广告起作用,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);
}
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合作?
解决了!以下是如何,希望它能帮助某人:

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);
}

解决了!以下是如何,希望它能帮助某人:

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上实现的你是如何在iOS上实现的