Reward and Interstitial in playing will be closed immediately when switching back from background
[REQUIRED] Step 1: Describe your environment
- Unity version: 2021.3.45f1
- Google Mobile Ads Unity plugin version: 9.5.0
- Plugin installation method: .unitypackage import
- Platform: Android
- Platform OS version: Android 11
- Any specific devices issue occurs on:
- Mediation ad networks used, and their versions:
[REQUIRED] Step 2: Describe the problem
Steps to reproduce:
0, Test with test device registered in admob web UI. 1, Show reward and interstitial ad in game and the ads played normally. 2, Switch the game to the background. 3, Switch the game back to foreground. 4, The playing ad will be closed immediately 5, Device log:
2025/02/19 17:30:29.248 8811 26353 Info FA Application backgrounded at: timestamp_millis: 1739957427242
2025/02/19 17:30:33.385 8811 26353 Info FA Application backgrounded at: timestamp_millis: 1739957431372
2025/02/19 17:30:37.306 8811 8873 Info Unity HandleRewardedAdPaidEvent: currency(USD) value(0)
2025/02/19 17:30:37.313 8811 8873 Info Unity HandleAdFullScreenContentClosedEvent received
Is this normal or the ad should continue playing when app swtiched back to foreground?
This is not normal,
Are you seeing this with test ad unit ids and the HelloWorld sample app?
This is not normal,
Are you seeing this with test ad unit ids and the HelloWorld sample app?
Hi, Thanks for your reply. I'll test the sample app and feedback later.
Hi, I test with the Samples/HelloWorld project from v9.5.0 on an Android 11 device and found this issue still exists.
Below is the steps to test (screen recroding attached by the end of this reply):
- Build and run HelloWorld on device:
2025/02/23 23:55:38.436 11597 11630 Info Unity MemoryManager: Using 'Dynamic Heap' Allocator.
2025/02/23 23:55:38.451 11597 11630 Info Unity SystemInfo CPU = ARM64 FP ASIMD AES, Cores = 8, Memory = 7614mb
2025/02/23 23:55:38.451 11597 11630 Info Unity SystemInfo ARM big.LITTLE configuration: 4 big (mask: 0xf0), 4 little (mask: 0xf)
2025/02/23 23:55:38.451 11597 11630 Info Unity ApplicationInfo com.DefaultCompany.HelloWorld version 1.0
2025/02/23 23:55:38.451 11597 11630 Info Unity Built from 'origin/2021.3/china_unity/release' branch, Version '2021.3.45f1c1 (9d8da11b98d3)', Build type 'Release', Scripting Backend 'mono', CPU 'armeabi-v7a', Stripping 'Disabled'
2025/02/23 23:55:38.536 11597 11630 Info Unity Company Name: DefaultCompany
2025/02/23 23:55:38.536 11597 11630 Info Unity Product Name: HelloWorld
2025/02/23 23:55:41.189 11597 11630 Info Unity Google Mobile Ads gathering consent.
2025/02/23 23:55:41.189 11597 11630 Info Unity Gathering consent.
2025/02/23 23:55:42.194 11597 11630 Info Unity Google Mobile Ads consent updated: NotRequired
2025/02/23 23:55:42.195 11597 11630 Info Unity Google Mobile Ads Initializing.
2025/02/23 23:55:42.334 11597 11630 Info Unity Adapter com.google.android.gms.ads.MobileAds is Ready
2025/02/23 23:55:42.334 11597 11630 Info Unity Adapter com.google.ads.mediation.vungle.VungleMediationAdapter is NotReady
2025/02/23 23:55:42.334 11597 11630 Info Unity Adapter com.google.ads.mediation.mintegral.MintegralMediationAdapter is NotReady
2025/02/23 23:55:42.334 11597 11630 Info Unity Adapter com.google.ads.mediation.pangle.PangleMediationAdapter is NotReady
2025/02/23 23:55:42.334 11597 11630 Info Unity Google Mobile Ads initialization complete.
- Enter
Rewarded Admenu and clickLoad Admenu
2025/02/23 23:56:01.608 11597 11630 Info Unity Loading rewarded ad.
2025/02/23 23:56:05.081 11597 11630 Info Unity Rewarded ad loaded with response : {
2025/02/23 23:56:05.081 11597 11630 Info Unity "Response ID": "EEW7Z57QOamOur8Pk57n-AM",
2025/02/23 23:56:05.081 11597 11630 Info Unity "Mediation Adapter Class Name": "com.google.ads.mediation.admob.AdMobAdapter",
2025/02/23 23:56:05.081 11597 11630 Info Unity "Adapter Responses": [
2025/02/23 23:56:05.081 11597 11630 Info Unity {
2025/02/23 23:56:05.081 11597 11630 Info Unity "Adapter": "com.google.ads.mediation.admob.AdMobAdapter",
2025/02/23 23:56:05.081 11597 11630 Info Unity "Latency": 1441,
2025/02/23 23:56:05.081 11597 11630 Info Unity "Ad Source Name": "Reservation campaign",
2025/02/23 23:56:05.081 11597 11630 Info Unity "Ad Source ID": "7068401028668408324",
2025/02/23 23:56:05.081 11597 11630 Info Unity "Ad Source Instance Name": "[DO NOT EDIT] Publisher Test Video Campaign",
2025/02/23 23:56:05.081 11597 11630 Info Unity "Ad Source Instance ID": "6877926149710223",
2025/02/23 23:56:05.081 11597 11630 Info Unity "Credentials": {
2025/02/23 23:56:05.081 11597 11630 Info Unity "pubid": "ca-app-pub-3940256099942544\/5224354917\/cak=no_cache&cadc=b0&caqid=EEW7Z4eoOMTjkPIPnZSZuQY",
2025/02/23 23:56:05.081 11597 11630 Info Unity "campaign_type": "1",
2025/02/23 23:56:05.081 11597 11630 Info Unity "campaign_id": "1057492276"
2025/02/23 23:56:05.081 11597 11630 Info Unity },
2025/02/23 23:56:05.081 11597 11630 Info Unity "Ad Error": "null"
2025/02/23 23:56:05.081 11597 11630 Info Unity }
2025/02/23 23:56:05.081 11597 11630 Info Unity ],
2025/02/23 23:56:05.081 11597 11630 Info Unity "Loaded Adapter Response": {
2025/02/23 23:56:05.081 11597 11630 Info Unity "Adapter": "com.google.ads.mediation.admob.AdMobAdapter",
2025/02/23 23:56:05.081 11597 11630 Info Unity "Latency": 1441,
2025/02/23 23:56:05.081 11597 11630 Info Unity "Ad Source Name": "Reservation campaign",
2025/02/23 23:56:05.081 11597 11630 Info Unity "Ad Source ID": "7068401028668408324",
2025/02/23 23:56:05.081 11597 11630 Info Unity "Ad Source Instance Name": "[DO NOT EDIT] Publisher Test Video Cam
- Click the
Show Admenu and the test reward video ad start to play
2025/02/23 23:56:22.283 11597 11630 Info Unity Showing rewarded ad.
-
Switch the app to background after 2 seconds playing (the countdown second displayed on ad start with 7)
-
Switch back to foreground and the playing video stopped immediately with below log messages:
2025/02/23 23:56:30.110 11597 11630 Info Unity Rewarded ad recorded an impression.
2025/02/23 23:56:30.110 11597 11630 Info Unity Rewarded ad full screen content opened.
2025/02/23 23:56:30.112 11597 11630 Info Unity Rewarded ad paid 0 USD.
2025/02/23 23:56:30.112 11597 11630 Info Unity Rewarded ad full screen content closed.
https://github.com/user-attachments/assets/e8b055ea-0a39-4e61-b18e-f01deaf178a4
Any update on this issue?
I was able to reproduce this behavior. In my case I notice this behavior only when the user clicks on the app icon to go back to the app. In case of foregrounding from swipe up or using the App Overview button in a 3 button navigation setup, I see the ad continues to play from where we left off. We will investigate this behavior further and get back to you. Thanks for the detailed report.
I was able to solve this by making a change to the AndroidManifest.xml file generated as part of the Unity Project.
Once the Android Project is exported, navigate to the project and find the manifest under unityLibrary/manifests/AndroidManifest.xml. Then find the launchmode attribute(android:launchMode). Unity sets it to singleTask but the default Android launch mode should be standard. Change the value to standard and run the app. The video should now continue from where you left off when you click on the app icon to foreground.
I was able to solve this by making a change to the AndroidManifest.xml file generated as part of the Unity Project. Once the Android Project is exported, navigate to the project and find the manifest under
unityLibrary/manifests/AndroidManifest.xml. Then find the launchmode attribute(android:launchMode). Unity sets it tosingleTaskbut the default Android launch mode should bestandard. Change the value tostandardand run the app. The video should now continue from where you left off when you click on the app icon to foreground.
Are you going to create a post-processing script or something to solve this inside the Admob package? Because we are not exporting the Android Project and I don't want to edit the Android Manifest file every time after the build is finished.
I was able to solve this by making a change to the AndroidManifest.xml file generated as part of the Unity Project. Once the Android Project is exported, navigate to the project and find the manifest under
unityLibrary/manifests/AndroidManifest.xml. Then find the launchmode attribute(android:launchMode). Unity sets it tosingleTaskbut the default Android launch mode should bestandard. Change the value tostandardand run the app. The video should now continue from where you left off when you click on the app icon to foreground.
Thanks for your reply. I'll try at my side. And I wonder if this change will affect other aspects of the app's behavior.
After changing the launchMode to standard, the ads now display as expected. However, after closing an interstitial ad, the game restarts, which seems unintended.
Any way to solve this problem?