3

Can a live wallpaper lock the screen in portrait mode? And if so, how?

I should mention that I have seen two supposed answers to this question on SO, one appeared inordinately complicated, I didn't understand it all and the answer was not accepted by the original poster. The second answer didn't work for me.

A third answer involving the use of:

android:screenOrientatin = "portrait" or "landscape"

has been suggested, but it is not clear exactly where this should go in the manifest.

EDIT: have tried putting android:screenOrientation="portrait" in many different places in the manifest, and none of them worked.

EDIT: another answer was to rotate your bitmaps and handle a rotation by just drawing everything sideways - but this looks very ugly because, as you rotate you phone, the OS instigates a rotation animation - which means that you get a horrid jumping effect as you turn the phone.

Mick
  • 8,284
  • 22
  • 81
  • 173
  • possible duplicate of [Prevent Live Wallpaper orientation change when an application is opened and orientation is changed?](http://stackoverflow.com/questions/4372936/prevent-live-wallpaper-orientation-change-when-an-application-is-opened-and-orie) – Peter O. Apr 23 '13 at 17:32
  • 1
    Please don't close this question before I have an answer that is A) unambiguous and B) works. – Mick Apr 23 '13 at 17:45
  • Create an invisible view and it works fine to me :) [http://stackoverflow.com/questions/14587085/how-can-i-globally-force-screen-orientation-in-android](http://stackoverflow.com/questions/14587085/how-can-i-globally-force-screen-orientation-in-android) – Matthew Nov 28 '15 at 22:07

4 Answers4

2

I'm beginning to suspect that the true answer is simply "no".

Mick
  • 8,284
  • 22
  • 81
  • 173
0

Did you try setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); ?

Leo
  • 3,003
  • 5
  • 38
  • 61
0

In your AndroidManifest.xml you should have something like:

    <application
    android:icon="@drawable/app_icon"
    android:label="@string/nuboLogin"
    android:name=".LoginApplication" 
     android:debuggable="true">
    <activity
        android:name=".WallPaperActivity"
        android:label="@string/wallPaper" 
        android:windowSoftInputMode="adjustPan" 
        android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" android:screenOrientation="portrait"
        android:configChanges="orientation|keyboardHidden">
    </activity>

This should make sure that your Activity runs in portrait mode. If you prefer landscape, you can easily guess what you should modify

EyalBellisha
  • 1,874
  • 19
  • 28
  • A wallpapr is a "service" not an activity... but anyway I tried adding android:screenOrientation="portrait" and it had no effect :-( – Mick May 02 '13 at 13:17
0

Android application restarts the activity when the orientation changes. You can either use

android:configChanges in your manifest. The activity is shut down and restarted by default, when a configuration change occurs at runtime, but declaring a configuration with this attribute will prevent the activity from being restarted. Instead, the activity remains running and its onConfigurationChanged() method is called.
use android:screenOrientatin = "portrait" or "landscape" it will force the app to run in the mode you specify. However it will not prevent the activity from being shut down and restarted.
Nagaraja
  • 581
  • 1
  • 4
  • 12