我在Android应用程序中使用来自admob的插页式广告。当我使用测试广告时,它们效果很好。但是,当我尝试使用自己的密钥上传广告时-广告成功加载的很少,而加载失败时-则会产生一条消息:
<!DOCTYPE html>
<html>
<head>
<title>Google Maps Example</title>
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 600px;
margin: 0;
padding: 0;
}
</style>
<script src="../src/data.json" type="text/javascript"></script>
</head>
<body>
<div>
<p style="text-align: center;">
Enter Merter Id:
<input type="text" value="" name="" id="meterId" placeholder="enter a meter id">
<button id="refresh" type="submit">Submit</button>
</p>
<br><br>
</div>
<div id="map"></div>
<p>Click on the map to add markers.</p>
<script>
var map;
var markers = [];
function initMap() {
var detroit = new google.maps.LatLng(42.3314,-83.0458);
map = new google.maps.Map(document.getElementById('map'), {
zoom: 12,
center: detroit,
mapTypeId: 'hybrid'
});
addMarker(detroit, "", "");
document.getElementById("refresh").addEventListener("click", addAllMarkers);
}
// Adds a marker to the map and push to the array.
function addMarker(location, icon, title) {
var marker = new google.maps.Marker({
position: location,
icon: icon,
title: title,
map: map
});
markers.push(marker);
}
// Sets the map on all markers in the array.
function setMapOnAll(map) {
for (var i = 0; i < markers.length; i++) {
markers[i].setMap(map);
}
}
// Removes the markers from the map, but keeps them in the array.
function clearMarkers() {
setMapOnAll(null);
}
// Shows any markers currently in the array.
function showMarkers() {
setMapOnAll(map);
}
// Deletes all markers in the array by removing references to them.
function deleteMarkers() {
clearMarkers();
markers = [];
}
function addAllMarkers(){
deleteMarkers();
var meterid = document.getElementById("meterId").value;
if ("" == meterid){
alert("A Meterid is required.");
return false;
}
var points = data.count;
alert("Data Points: " + points);
for (i = 0; i < points; i++) {
var latlng = new google.maps.LatLng(data.photos[i].latitude,data.photos[i].longitude);
var title = "";
addMarker(latlng, data.photos[i].icon, title);
}
setMapOnAll();
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?&callback=initMap">
</script>
</body>
</html>
我什么都没找到。 Google保持沉默。
我的代码:
Precache abort but no precache task running
LogCat:
public class AndroidLauncher extends AndroidApplication{
InterstitialAd mInterstitialAd;
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
MobileAds.initialize(this,
"MYAPPKEY");
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("MYINTERKEY");
final MyGdxGame game = new Game(), ad);
View gameView = initializeForView(game, config);
final AdRequest.Builder builder = new AdRequest.Builder();
builder.addTestDevice("DEVICEKEY");
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
System.out.println("Ads: InterLoaded");
mInterstitialAd.show();
}
@Override
public void onAdClosed() {
mInterstitialAd.loadAd(builder.build());
System.out.println("Ads: InterClosed");
}
@Override
public void onAdFailedToLoad(int var1) {
System.out.println("Ads: InterFailed");
}
});
RelativeLayout layout = new RelativeLayout(this);
layout.addView(gameView);
RelativeLayout.LayoutParams adParams =
new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
adParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
adParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
setContentView(layout);
mInterstitialAd.loadAd(builder.build());
}
}