Handling Orientation Changes in IMA Player

37 views
Skip to first unread message

Anas Mirza

unread,
Apr 15, 2024, 9:51:51 AMApr 15
to Interactive Media Ads SDK
I'm encountering difficulty managing orientation changes in the IMA player. My application has separate layouts for portrait and landscape modes. Integrating orientation checks in the configuration changes isn't viable due to the layout discrepancies. While this setup functions smoothly with the ExoPlayer, I'm unsure how to approach it with the IMA player. Any insights or guidance on handling this situation would be appreciated.

IMA SDK

unread,
Apr 15, 2024, 10:46:39 AMApr 15
to anas....@rooter.io, ima...@googlegroups.com
Hey Anas,

Thanks for contacting us.

Can you share full context of your issue, what exactly you are facing with IMA SDK ?
In case you are having issue with ad view or player not adjusting while rotating,  kindly take help from Google Sample Project.

Also share Screen Recordings or Sample Project to us so that we can see the issue.

If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files with me by performing the following steps:

1. Navigate to

https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=IMA+SDK&entry.460850823=5004Q00002tP6MkQAK&entry.80707362=00231179

2. Fill out all fields, and attach your file(s).

3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link.

This message is in relation to case "ref:!00D1U01174p.!5004Q02tP6Mk:ref" (ADR-00231179)

Thanks,
 
Google Logo IMA SDK Team


Anas Mirza

unread,
Apr 22, 2024, 9:00:12 PMApr 22
to Interactive Media Ads SDK
Hi Team

I'm encountering an issue with managing orientation changes in my application, which has separate layouts for portrait and landscape modes. I've provided a sample project here to illustrate the problem.

The problem arises when attempting to manage configuration changes in the AndroidManifest file. If I include checks for configuration changes, I'm unable to switch between layouts. However, if I remove these checks, I encounter difficulties in resuming the ad properly, particularly in landscape mode.

I'm seeking an optimized solution to ensure that the ad resumes correctly while also allowing for layout changes during orientation switches. Could someone provide guidance or a recommended approach to address this issue?

IMA SDK

unread,
Apr 23, 2024, 8:13:47 AMApr 23
to anas....@rooter.io, ima...@googlegroups.com
Hi Anas,

Thank you for providing the Sample Project, i am checking the sample app, i will get back to you once i have got the solution to load ads perfectly while changing orientation.

IMA SDK

unread,
Apr 23, 2024, 1:12:05 PMApr 23
to ima...@googlegroups.com, anas....@rooter.io
Hi Anas,

I've checked your shared Sample Project and found that your landscape xml file not loading while rotating the device to landscape.

Please note this is an integration issue. This can be checked by removing activity_my.xml inside _land folder and launch the app, app will behave same.
To resolve this issue, you can put some check in onCreate method which will store the orientation information from context.
int orientation = config.orientation;

Then recreate your xml file for landscape and give some other name like activity_my_land.xml and put inside layout folder. Now in onCreate method put some condition like if orientation found as portrait then load activity_my_.xml if landscape then set layout ID as activity_my_land.xml.

 if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
 layoutId = R.layout.activity_my; }
else { layoutId = R.layout.activity_my_land; 
}
setContentView(layoutId);

After these configuration try to run app again and utilizing all shared property inside configChanges will work perfectly and no UI issue will come.
Reply all
Reply to author
Forward
0 new messages