我向Google移动广告SDK发出广告请求,并设置AdListener以收听广告事件。但是,对于某些广告,未调用onAdOpened()/ onAdLeftApplication()并且我无法在外部Web浏览器中显示该广告。相反,我可以在广告视图中与广告互动。我可以使用SDK在外部应用程序中始终打开广告吗?
以下是AdView:
final AdView adView = new AdView(activity);
adView.setAdSize(adSize);
adView.setAdUnitId(adUnitId);
adView.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
Log.d(TAG, "onAdLoaded");
}
@Override
public void onAdFailedToLoad(int errorCode) {
String error = "";
switch (errorCode) {
case AdRequest.ERROR_CODE_INTERNAL_ERROR:
error = "ERROR_CODE_INTERNAL_ERROR. Something happened internally; for instance, an invalid response was received from the ad server.";
break;
case AdRequest.ERROR_CODE_INVALID_REQUEST:
error = "ERROR_CODE_INVALID_REQUEST. The ad request was invalid; for instance, the ad unit ID was incorrect.";
break;
case AdRequest.ERROR_CODE_NETWORK_ERROR:
error = "ERROR_CODE_NETWORK_ERROR. The ad request was unsuccessful due to network connectivity.";
break;
case AdRequest.ERROR_CODE_NO_FILL:
error = "ERROR_CODE_NO_FILL. The ad request was successful, but no ad was returned due to lack of ad inventory.";
break;
default:
break;
}
}
@Override
public void onAdOpened() {
Log.d(TAG, "onAdOpened");
}
@Override
public void onAdClosed() {
Log.d(TAG, "onAdClosed");
}
@Override
public void onAdLeftApplication() {
Log.d(TAG, "onAdLeftApplication");
}
});
并加载广告:
AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).addTestDevice(deviceid).build();
// Start loading the ad in the background.
adView.loadAd(adRequest);
答案 0 :(得分:-2)
adView.setAdListener(new AdListener() {
public void onAdLeftApplication (){
t1 = (TextView) findViewById(R.id.textView2);
t1.setText("5000");
}
}