简体   繁体   中英

Screen orientation getting stuck on emulator

I have a video player implemented in an activity. I am forcing it into landscape at this stage by doing setting up the manifest like this

<activity android:name=".activity.VideoPlayerActivity"
              android:launchMode="singleTask"
              android:configChanges="orientation"
              android:screenOrientation="landscape"/>

and overriding onConfigurationChanged with an empty implementation so that the activity is not restarted.

This all works great but at least on the emulator it seems to affect other activities forcing them into landscape even though they share nothing in terms of code. I have no seen this happen on any phone yet but obviously I have a limited amount of phones and I would really not like this to happen to users.

So has anybody seen this problem before? Is it just the emulator? Is there maybe a better way to do it?

Or considering tablets and so on coming along should I stop to force landscape mode anyway and just keep track of the position in the video and restart at the right position upon orientation change?

I think that's an emulator thing; I'm sure I've seen similar, but never on any phone.

Also, your Activity can be restarted by various configChanges, including a hardware keyboard sliding in/out, or change of locale, or day/night mode?

Best to allow the user to choose and keep track of the position, like you say.
Maybe you can even hold onto the MediaPlayer (or whatever) you're using via onRetainNonConfigurationInstance() .

Well think of how you are using it....you would hyppothetically turn the emulator on its side, just like the user would turn the phone to watch the video in that orientation. so if no other apps are forcing a specific orientation, it will remain in that orientation. You can cahnge the emulators orientation by hitting:

ctrl+f2+f12

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM