我有一个通知应用程序,它从未以 99 美分的价格流行起来。所以我正在尝试免费的广告模式。
问题是,Admob 很慢。它的加载时间在 Activity 显示后长达七秒。该 Activity 只是一个通知,因此用户会在广告有机会加载之前关闭应用。
我有一个打开 Activity 的服务。
服务:
Intent notificationIntent = new Intent(this, FullScreen.class);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
NotificationManager nm = (NotificationManager) this
.getSystemService(Context.NOTIFICATION_SERVICE);
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
Notification notif;
if (currentapiVersion >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
Notification.Builder builder = new Notification.Builder(context)
.setWhen(System.currentTimeMillis())
.setContentIntent(contentIntent)
notif = builder.build();
} else {
notif = new Notification.Builder(context)
.setWhen(System.currentTimeMillis())
.setContentIntent(contentIntent)
}
Activity 的 onCreate 中的 Admob 代码(从 admob 的文档中剪切 n 粘贴):
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
Activity 加载速度很快,我不想延迟到 AdView 加载。有什么方法可以让 AdView 在服务期间加载,然后将其传递给 Activity 吗?我猜没有。这是设计使然,人们无法在他们的应用中获得大量虚假广告印象。
最佳答案
您可能不想听到这个,但听起来您的应用不太适合广告收入模式。
您需要一个 UI 上下文才能加载广告。除非在非常有限的时间段内,否则您没有 UI 上下文。
正如您所注意到的,加载 a 需要时间,而您没有。
关于android - 我可以加快 Admob 在 Android 上的加载速度吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32383254/