Admob的应用程序的第一个执行过程中不显示。 2 [英] Admob is not displayed during the app's first execution. 2
问题描述
我做了一个Android应用程序与PhoneGap的(科尔多瓦2.5.0)。我把AdMob的在我的应用程序使用这个插件。 ( https://github.com/sainttex/PhoneGap-Android-Native-AdMob)
Admob的显示在我的应用程序。但是,有一个问题。在第一次执行,AdMob的没有显示出来。关闭应用程序,并重新启动它后,将显示的AdMob。从第二次起执行,显示AdMob的。
如果我不使用的应用程序,一段时间(约一小时),然后运行该应用程序,该问题再次出现。
我能做些什么来解决问题呢?
·贝娄是我的code。
[MainActivity.java code]
。 包COM *** *******;
进口com.google.ads *。
进口org.apache.cordova.DroidGap;
进口android.os.Bundle;
进口android.widget.LinearLayout;
//进口android.view.Menu;
公共类MainActivity扩展DroidGap {
私有静态最后弦乐AdMob_Ad_Unit =*************;
私人AD浏览报AD浏览报;
@覆盖
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
AD浏览报=新的AD浏览报(这一点,AdSize.BANNER,AdMob_Ad_Unit);
的LinearLayout布局= super.root;
layout.addView(AD浏览报);
AdRequest请求=新AdRequest();
adView.loadAd(要求);
super.loadUrl(文件:///android_asset/www/index.html);
}
}
[AndroidManifest.xml中code]
<活动机器人:名称=com.google.ads.AdActivity
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
安装科尔多瓦AdMob的插件。
科尔多瓦插件添加com.admob.AdmobPlugin
再增加code。
函数onDeviceReady(){
admobAd.initBanner("ca-app-pub-1738093038576474/9839543541",admobAd.AD_SIZE.BANNER.width,admobAd.AD_SIZE.BANNER.height);//ios间质性
admobAd.showBanner(admobAd.AD_POSITION.BOTTOM_CENTER);
}
document.addEventListener(deviceready',onDeviceReady,假);
I made an Android app with Phonegap (Cordova 2.5.0). And I put admob in my app using this plugin. ( https://github.com/sainttex/PhoneGap-Android-Native-AdMob )
Admob is displayed in my app. But there's a problem. During the first execution, admob's not showing up. After closing the app and re-starting it, admob is displayed. From the second execution onwards, admob is displayed.
If I don't use the app for a while (about one hour), then run the app, the problem comes up again.
What can I do to fix problem?
Bellow is my code.
[MainActivity.java code]
package com.***.*******;
import com.google.ads.*;
import org.apache.cordova.DroidGap;
import android.os.Bundle;
import android.widget.LinearLayout;
//import android.view.Menu;
public class MainActivity extends DroidGap {
private static final String AdMob_Ad_Unit = "*************";
private AdView adView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
adView = new AdView(this, AdSize.BANNER, AdMob_Ad_Unit);
LinearLayout layout = super.root;
layout.addView(adView);
AdRequest request = new AdRequest();
adView.loadAd(request);
super.loadUrl("file:///android_asset/www/index.html");
}
}
[AndroidManifest.xml code]
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
Install cordova admob plugin.
cordova plugin add com.admob.AdmobPlugin
Then add this code.
function onDeviceReady() {
admobAd.initBanner("ca-app-pub-1738093038576474/9839543541",admobAd.AD_SIZE.BANNER.width,admobAd.AD_SIZE.BANNER.height);//ios Interstitial
admobAd.showBanner(admobAd.AD_POSITION.BOTTOM_CENTER);
}
document.addEventListener('deviceready',onDeviceReady, false);
这篇关于Admob的应用程序的第一个执行过程中不显示。 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!