Reputation: 116392
I have an activity which shows a full screen videoView (yet maintain the aspect ratio). It worked perfectly on Android 2.3.7, but i'm having some weird problems on Android 4 (and probably 3, i didn't check yet):
For some reason, if I set the theme to be full screen, without the titlebar (or action bar), i get a blue-ish (or white-ish?) gradient below the videoView, as shown here:
The relevant layout is here:
edit: on android 3 , it doesn't occur.
When I change the orientation from portrait to landscape, it re-loads the whole video from the beginning. On Android 2.3.7, it continued without any delay, as if nothing has changed.
The relevant manifest part is here:
<activity android:name=".activities.player_activity.PlayerActivity" android:configChanges="keyboardHidden|orientation"
android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" android:screenOrientation="sensor"/>
Note that on Android 3, rotating the tablet doesn't do anything, so there is no orientation change.
How should I handle those problems ? The API demos don't seem to be updated to handle those cases.
My project was tested on: nexus one (android 2.3.7) , xoom (android 3) , galaxy S3 (android 4).
In order to fix number 1, I've simply changed the theme that doesn't have any background. Odd that it's this way on the device. Wonder if it's like this on other Android 4 devices. In order to create the theme, I've created a file "theme.xml" in the "res/values/" folder, and wrote there:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.FullScreenNobarsNoBackground" parent="@android:style/Theme.Holo.NoActionBar.Fullscreen">
<item name="android:windowBackground">@null</item>
</style>
</resources>
Of course I've also updated the manifest to use the new theme.
Upvotes: 1
Views: 2574
Reputation: 8828
I'm afraid I can't see the gradient you're talking about on that image. But if it is on the whole screen, then this is probably the standard background for Holo themes and you can just remove it using a custom theme.
As for the restarting on rotation, you could save the current time in onConfigurationChanged(..) and then use VideoView.seekTo(..) to then get it back to the correct time in an appropriate part of your code. However, I don't know why this should happen in ICS because you're not destroying the Activity.
Upvotes: 0
Reputation: 461
When you change the device orientation, the Dalvik kills the activity and create another, and garbage collector clean all the old stuff.
I suggest to you forces the application stay in horizontal mode, you can do that change the follow attribute in activity:
<activity android:screenOrientation="landscape" />
If you wanna the activy change the orientation, you must handler the change. You can read this documentation how to handling runtime changes.
Upvotes: 1