android - Interstitial not loading.? -
public class mainactivity extends actionbaractivity { interstitialad minterstitialad; @override public void onbackpressed() { showad(); finish(); } @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); minterstitialad = new interstitialad(this); //minterstitialad.setadunitid(string.valueof(r.string.interstitial_ad_unit_id)); //minterstitialad.setadunitid(getstring(r.string.interstitial_ad_unit_id)); minterstitialad.setadunitid("ca-app-pub-6342248862135370/7323606247"); requestnewinterstitial(); minterstitialad.setadlistener(new adlistener() { @override public void onadfailedtoload(int errorcode) { toast.maketext(getapplicationcontext(),"ad failed load", toast.length_short).show(); } @override public void onadloaded() { toast.maketext(getapplicationcontext(),"ad loaded", toast.length_short).show(); } @override public void onadclosed(){requestnewinterstitial();} }); //load ad starts adview madview=(adview) findviewbyid(r.id.adview); adrequest adrequest = new adrequest.builder().build(); madview.loadad(adrequest); //load ad stops } public void second(view view){ intent = new intent(getapplicationcontext(), second.class); startactivity(i); } public void showad(){ if(minterstitialad.isloaded()){ toast.maketext(getapplication(), "the ad has loaded.", toast.length_short).show(); minterstitialad.show(); } else toast.maketext(getapplication(), "the ad has not loaded yet.", toast.length_short).show(); } public void requestnewinterstitial() { adrequest adrequest = new adrequest.builder().build(); minterstitialad.loadad(adrequest); } }
my problem shows toast "ad failed load".i don't know missing in code. please help!!. , have searched lot on please don't post links questions.
manifest
<?xml version="1.0" encoding="utf-8"?> <!-- include required permissions google mobile ads run --> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme"> <!-- meta-data tag required use google play services. --> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <activity android:name=".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 adactivity configchanges , 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" /> <activity android:name=".second" android:label="@string/title_activity_second"></activity> <activity android:name=".third" android:label="@string/title_activity_third"></activity> </application> logcat
logcat says:
06-01 00:59:20.883 16251-16326/abc.myapplication i/ads﹕ no fill ad server. that why not getting ads. there none available @ time, place , device. if want test need set test adunitid. given logcat:
06-01 00:59:20.159 16251-16251/abc.myapplication i/ads﹕ use adrequest.builder.addtestdevice("1cc3c3cdc4d015059d600fe0d095eae5") test ads on device.
Comments
Post a Comment