Reputation: 51
In my main class in
@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
}
Without MobileAds.initialize() my foreground service is not being killed when i'm closing application. With MobileAds.initialize() my foreground service is being killed.
Does any one know why? How to solve that?
Upvotes: 0
Views: 99
Reputation: 1
You must clear this line
MobileAds.initialize(this,"ca-app-pub-3940256099942544/6300978111");
And add the following line to the manifest instead
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
Upvotes: 0