【发布时间】:2019-11-21 22:16:55
【问题描述】:
在我的主课中
@Override
protected void onCreate(Bundle savedInstanceState) {
{
..some code
//first start foreground service
Intent serviceIntent = new Intent(this, ForegroundService.class);
ContextCompat.startForegroundService(this, serviceIntent);
//then i'm starting admob
MobileAds.initialize(this,"ca-app-pub-3940256099942544/6300978111");
mAddView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAddView.loadAd(adRequest);
..some code
}
如果没有 MobileAds.initialize(),当我关闭应用程序时,我的前台服务不会被终止。 使用 MobileAds.initialize() 我的前台服务被杀死了。
有人知道为什么吗?如何解决?
【问题讨论】:
标签: android admob foreground-service googlemobileads