Android 7 - displayed banner ad removes Night Mode from activity

1,536 views
Skip to first unread message

Christopher

unread,
Aug 2, 2016, 9:54:14 AM8/2/16
to Google Mobile Ads SDK Developers
Hello,

I display banner ads from AdMob. My app use "Theme.AppCompat.DayNight" style to apply DAY MODE or DARK MODE.

I set "AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)" when app is started.

Everything is fine on all Android version, except new Android 7 BETA.

boolean isNightMode = (activity.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;

Above value "isNightMode" is TRUE when activity is created. But after banner ad is displayed value "isNightMode" is FALSE and some views of my activity are with light style. It looks awful.

I tested with "compile 'com.google.android.gms:play-services-ads:8.3.0'" and "compile 'com.google.android.gms:play-services-ads:9.2.0'". Same issue.
I tested with "targetSdkVersion 23" and "targetSdkVersion 24". Same issue.
I tested on both phisical device (Nexus 5X) and emulators. Same issue.

Could you please fix this?

Vu Chau (Mobile Ads SDK Team)

unread,
Aug 2, 2016, 12:29:27 PM8/2/16
to Google Mobile Ads SDK Developers
Hi Christopher,

Thanks for drawing our attention to this! I was able to reproduce this behavior as well on my end, and I have let the rest of the team know.  

We will ping this thread once there is an update.

Vu Chau
Mobile Ads SDK Team

Michael Vescovo

unread,
Apr 22, 2017, 12:54:14 PM4/22/17
to Google Mobile Ads SDK Developers
I've also been experiencing this problem. Seems there is no workaround. Even if I manually set to night mode in the fragment it still won't do it. I tried doing it at the start of onCreateView and also after the ad is loaded. Really annoying since the app looks nice in night mode.

Deepika Uragayala- MobileAds SDK team

unread,
Apr 24, 2017, 10:41:36 AM4/24/17
to Google Mobile Ads SDK Developers
Hi Michael,

Our team is still working on this. I will ping this thread and update here if I have any new information.

Regards,
Deepika Uragyala
Mobile AdsSDK Team

Diego Souza

unread,
May 9, 2017, 5:33:28 PM5/9/17
to Google Mobile Ads SDK Developers
Hello,

I'm share the video about my problem, the app is running like this in production. I allowed ads only for this screen. 
The major screens in app has ads, but I load it only for android 6 and lower, because 7 and higher broke all views, some dark and others default(light)

E.g. This screen is a listview with DayNight like Chistopher has mentioned. The white item (cardview) is wrong, taking default theme entead of dark.

I already duplicated the drawables, and layouts for -night extension folder, but without success.

No more ideas :(

Deepika Uragayala- MobileAds SDK team

unread,
May 10, 2017, 10:57:12 AM5/10/17
to Google Mobile Ads SDK Developers
Hi Diego,

Thanks for sharing the video. I have passed this to the rest of the team and I will update this thread as soon as I have any new information.

Regards,
Deepika Uragayala
Mobile Ads SDK Team

Deepika Uragayala- MobileAds SDK team

unread,
May 10, 2017, 4:01:52 PM5/10/17
to Google Mobile Ads SDK Developers
Hi Diego,

The white item doesn't look like an AdView. However, can you send us - Charles logs, device logs, Ad Unit IDs and a sample app which helps us to investigate this issue further?

Regards,
Deepika Uragayala
Mobile Ads SDK Team


On Tuesday, May 9, 2017 at 5:33:28 PM UTC-4, Diego Souza wrote:

Kamil Karbowski

unread,
May 12, 2017, 8:05:42 AM5/12/17
to Google Mobile Ads SDK Developers
Hi,
I have the same issue with my app and spent two weeks trying to fix this till I found this thread.
In my app the problem only appears when I use AdMob with DayNight theme in night mode.
The only one workaround that I found is to set night mode globally with "UiModeManager.setNightMode(UiModeManager.MODE_NIGHT_YES)" but this make another issue with statusbar on some devices (statusbar is getting dark).

Interesting thing is that screen rotation fix this problem (till i restart app).

I recorded three videos to show this issue - I used here Genymotion emulator but this also appears on the real devices.

1. App with AdMob:

2. App wthout AdMob:

3. App with AdMob and I made screen rotation that magically fixes problem (sorry for rotation lag):

Diego Souza

unread,
May 12, 2017, 8:29:35 AM5/12/17
to google-adm...@googlegroups.com
You are right, if rotation event or call recreate method. 

If you add ads in footer of listview, the problem apear only after you view ads and scroll (other event after ads load and show).

It's so crazy

Att,

Diego Souza

--

---
You received this message because you are subscribed to a topic in the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-admob-ads-sdk/OZzHq_-wAFY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Deepika Uragayala- MobileAds SDK team

unread,
May 12, 2017, 12:08:39 PM5/12/17
to Google Mobile Ads SDK Developers
Hi Kamil/Diego,,

Thanks for sharing the details. I will pass this to the rest of the team for further investigation. I will ping this thread as soon as I have any new information.

Regards,
Deepika Uragayala
Mobile Ads SDK Team

Kamil Karbowski

unread,
May 12, 2017, 12:37:46 PM5/12/17
to Google Mobile Ads SDK Developers
Hi Deepika, 
I hope that You really working on it. It's more than 9 months after one of Your team member was able to reproduce this behavior - after this time still isn't fixed.
To post to this group, send email to google-adm...@googlegroups.com.

Diego Souza

unread,
May 17, 2017, 1:12:50 AM5/17/17
to google-adm...@googlegroups.com
Hi,

I'm sharing a new video (big) using this project and problems.


Regards,

Att,

Diego Souza

To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsubscrib...@googlegroups.com.

To post to this group, send email to google-admob-ads-sdk@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Deepika Uragayala- MobileAds SDK team

unread,
May 17, 2017, 2:21:46 PM5/17/17
to Google Mobile Ads SDK Developers
Hi Diego,

Thanks for sharing the additional information. I will pass this to the team and update this thread as soon as I have any new information.

Regards,
Deepika Uragayala
Mobile Ads SDK Team

On Wednesday, May 17, 2017 at 1:12:50 AM UTC-4, Diego Souza wrote:
Hi,

I'm sharing a new video (big) using this project and problems.


Regards,

Att,

Diego Souza
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kamil Karbowski

unread,
May 20, 2017, 5:21:59 AM5/20/17
to Google Mobile Ads SDK Developers
One of user from stackoverflow (Mateusz Kaflowski) reproduced this issue and posted code on github:


W dniu środa, 17 maja 2017 20:21:46 UTC+2 użytkownik Deepika Uragayala- MobileAds SDK team napisał:
Hi Diego,

Thanks for sharing the additional information. I will pass this to the team and update this thread as soon as I have any new information.

Regards,
Deepika Uragayala
Mobile Ads SDK Team

On Wednesday, May 17, 2017 at 1:12:50 AM UTC-4, Diego Souza wrote:
Hi,

I'm sharing a new video (big) using this project and problems.


Regards,

Att,

Diego Souza
To post to this group, send email to google-adm...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to a topic in the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-admob-ads-sdk/OZzHq_-wAFY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-adm...@googlegroups.com.

Deepika Uragayala- MobileAds SDK team

unread,
May 22, 2017, 2:38:02 PM5/22/17
to Google Mobile Ads SDK Developers
Hi Kamil,

Thanks for sharing more details. I will pass this to the team and will update this thread if we have any new information.

Regards,
Deepika Uragayala
Mobile Ads SDK Team

Lyudmila Kostik

unread,
May 29, 2017, 11:37:38 AM5/29/17
to Google Mobile Ads SDK Developers
Same trouble. Please fix it:(

Joshua Lagonera (Mobile Ads SDK Team)

unread,
May 29, 2017, 11:58:55 PM5/29/17
to Google Mobile Ads SDK Developers
Hi Lyudmila,

This issue is still currently being investigated by the team. As previously stated by my colleague, Deepika, we will update you once we have additional information.

Regards,
Joshua Lagonera
Mobile Ads SDK Team

Diego Souza

unread,
May 30, 2017, 12:23:57 AM5/30/17
to google-adm...@googlegroups.com
If you start app from Android Studio start button, and stay in dark mode, only change something in xml(ui) and restart app with instant run button. All content lost dark mode, it's bad and not good behavior.

But it's easy for test(debug)

Att,

Diego Souza

--

---
You received this message because you are subscribed to a topic in the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-admob-ads-sdk/OZzHq_-wAFY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.

Christopher

unread,
Jun 13, 2017, 8:37:45 AM6/13/17
to Google Mobile Ads SDK Developers
I tested with the newest version "compile 'com.google.android.gms:play-services-ads:11.0.0'" and this bug still occurs. Could you please fix it?

Diego Souza

unread,
Jun 13, 2017, 8:48:22 AM6/13/17
to google-adm...@googlegroups.com
I changed my implementation, remove day night theme and create one theme for light and other for dark.

This gave me a lot of work but, fix it definitely.

2017-06-09 11:37 GMT-03:00 Christopher <krzysztof.e...@gmail.com>:
I tested with the newest version "compile 'com.google.android.gms:play-services-ads:11.0.0'" and this bug still occurs. Could you please fix it?

--

---
You received this message because you are subscribed to a topic in the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-admob-ads-sdk/OZzHq_-wAFY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Diego Souza
Skype: diego.knupffer

Deepika Uragayala- MobileAds SDK team

unread,
Jun 13, 2017, 3:23:12 PM6/13/17
to Google Mobile Ads SDK Developers
Hi Diego,

Glad that you found a work around. I will ping this thread and update you about the fix as soon as I have any new information.
Regards,
Deepika Uragayala
Mobile Ads SDK Team

On Tuesday, June 13, 2017 at 8:48:22 AM UTC-4, Diego Souza wrote:
I changed my implementation, remove day night theme and create one theme for light and other for dark.

This gave me a lot of work but, fix it definitely.

Christopher

unread,
Jun 14, 2017, 1:21:48 AM6/14/17
to Google Mobile Ads SDK Developers
Yes, I did the same. Now, I'm using a lot of attributes (?attr/...) in layout files. But it's a pity because "day-night" was very comfortable.

Christopher

unread,
Jun 23, 2017, 4:49:41 AM6/23/17
to Google Mobile Ads SDK Developers
There is another bug when displaying ad from AdMob. In addition to corruption "night mode", there are also locales corrupted.
I'm using "Locale.setDefault(newLocale)", but after displaying ad my locales are removed.
I'm using custom locales because there is ability to change app language in my apps. However after displaying ad, device language is displayed instead of language selected by user.

Deepika Uragayala- MobileAds SDK team

unread,
Jun 23, 2017, 2:54:46 PM6/23/17
to Google Mobile Ads SDK Developers
Hi Christopher,

Thanks for bringing this to our attention. I would suggest that you open a new thread for this issue with detailed steps for how to replicate this behaviour and also send us your Ad Unit ID, your app link or a sample project so that we can investigate further.

Regards,
Deepika Uragayala
Mobile Ads SDK Team

Kamil Karbowski

unread,
Jun 25, 2017, 9:48:17 AM6/25/17
to Google Mobile Ads SDK Developers
Better solution than changing implementation of night theme is just change ads provider. As we can see it is almost one year when one of SDK Team member reproduced this issue and till today they didnt nothing to fix it.

Deepika Uragayala- MobileAds SDK team

unread,
Jul 11, 2017, 3:38:02 PM7/11/17
to Google Mobile Ads SDK Developers
Hi Everyone,

Thank you for your continued patience. Our team has investigated this issue and found that this is not specific to ads. When the uiMode is reset the first time a WebView is created which is causing the issue. A workaround for this would be to instantiate WebView once at startup, before setting night mode. The Night mode works correctly with ads after that.

Let us know if you still continue to see the issue and I will bring this up with the team again.

Regards,
Deepika Uragyaala
Mobile Ads SDK Team

sindhu hegde

unread,
Oct 9, 2017, 5:44:51 AM10/9/17
to Google Mobile Ads SDK Developers
Hi Deepika,
         I'm also facing similar issue in my app.Im using textview to diaplay text where parent layout is cardview.In android 7 when night mode is ON,cardview color is not displaying properly its a combination of white and black cardview where it should display only black cardview in night mode(PFA).Please help me with this.
IMG-20171005-WA0005.jpg

Deepika Uragayala- MobileAds SDK team

unread,
Oct 9, 2017, 2:48:51 PM10/9/17
to Google Mobile Ads SDK Developers
Hi Sindhu, 

We determined previously that the night mode issue is a general Android problem unrelated to the Mobile Ads SDK.  I also don't see any ads in your screenshot, which leads me to believe that you're not using our SDK. Assuming that's correct, you'll have to look for assistance somewhere that supports general Android inquiries. I would recommend StackOverflow, or similar.

Regards,
Deepika Uragayala
Mobile Ads SDK Team

sindhu hegde

unread,
Oct 10, 2017, 1:42:24 AM10/10/17
to Google Mobile Ads SDK Developers
Thank u Deepika.
Sorry for not providing full info.

Ads : DFP Ads
Dependency : compile 'com.google.android.gms:play-services-ads:10.2.1'
Version : Android 7
Issue: Whenever i implement DFP ads to my app ,in night mode it is acting weirdly(PFA).Even text color is changing.If i remove ads its working properly.So i'm confused its Ads issue or any general android problem.
Screenshot_2017-10-10-10-59-51-900_in.oneindia.sixtysecnewsnow.png
Screenshot_2017-10-10-10-59-38-973_in.oneindia.sixtysecnewsnow.png
Screenshot_2017-10-10-10-59-10-839_in.oneindia.sixtysecnewsnow.png

Deepika Uragayala- MobileAds SDK team

unread,
Oct 10, 2017, 2:42:48 PM10/10/17
to Google Mobile Ads SDK Developers
Hi Sindhu

Thanks for clarifying with more details. Can you confirm whether this is still happening with the latest  version of our SDK? Also, can you check with our sample apps and let us know if you are able to reproduce the issue? As mentioned my previous posts, a workaround for this would be to instantiate WebView once at startup, before setting night mode. The Night mode works correctly with ads after that.

Let us if you are still seeing the issue even after applying the workaround.

Regards,
Deepika Uragayala
Mobile Ads SDK Team

sindhu hegde

unread,
Oct 11, 2017, 3:12:41 AM10/11/17
to Google Mobile Ads SDK Developers
Hi Deepika,

1.I tried with com.google.android.gms:play-services-ads:11.0.4,its not working.
2.I'm unable to recreate the issue in sample app may be bcoz its 1 page(we are using cardview inside recyclerview).
3.I'm creating PublisherAdview(DFP) dynamically everytime before showing Ad.If i add PublisherAdview in xml file ,its not working.

PublisherAdView publisherAdView=new PublisherAdView(context);
publisherAdView.setAdSizes(AdSize.LARGE_BANNER);
publisherAdView.setAdUnitId(DFP_LARGE_BANNER_ID);
PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build();
publisherAdView.loadAd(adRequest);

In the above code if i comment loadAd line,then App works fine.

As u suggested i tried instantiate  PublisherAdView before calling nightmode,then also its not working.

May be the way i implemented Ads code is wrong,OR instantiating PublisherAdView is wrong,So little confused with this.Please help me out with this OR give me code snippet to instantiate it.

Thanks in advance.

Chris Feldman (Mobile Ads SDK Team)

unread,
Oct 11, 2017, 3:02:43 PM10/11/17
to Google Mobile Ads SDK Developers
Hi Sindhu,

You're correct that your SDK code is causing this behavior. However, the issue is not with the SDK, but with Android in general. The problem is that Android is resetting the uiMode the first time a WebView is instantiated. Because the SDK uses WebViews, it is resetting night mode upon SDK initialization. This is unavoidable from a Mobile Ads SDK perspective.

As a workaround, we have found that instantiating a WebView immediately before turning on night mode and initializing the SDK solves the issue. If this is no longer working, I would again suggest looking for support somewhere that deals with general Android issues.

Regards,
Chris Feldman
Mobile Ads SDK Team
Message has been deleted

sdk locator

unread,
Aug 15, 2019, 12:08:18 AM8/15/19
to Google Mobile Ads SDK Developers

Anyone find a work around for this without having to keep two separate light and dark themes? The problem I am running into is documented here. It is kind of bad for us because we use the webview for app a lot. It is going to be a big change to get rid of it now. :(

Mobile Ads SDK Forum Advisor Prod

unread,
Aug 15, 2019, 1:28:49 AM8/15/19
to c9177...@gmail.com, google-adm...@googlegroups.com
Hi there,

Thank you for reaching out to us.

As per the rest of the thread, you may try instantiating a WebView as a workaround, just before turning on night mode and initializing the SDK. I would also recommend posting your concern over to StackOverflow, as this is more of an Android-related implementation issue than an SDK-related one.

Regards,
Ziv Yves Sanchez
Mobile Ads SDK Team

ref:_00D1U1174p._5001UEJ99x:ref
Reply all
Reply to author
Forward
0 new messages