Android :: Disable Orientation Change In Android?
Oct 2, 2009
I have an application that I just would like to use in portrait mode, so I have defined
android: screenOrientation="portrait" in the manifest xml. This works ok for the htc magic phone. But I have a problem with the HTC G1 phone as i open the hardware qwerty keyboard (not the virtual keyboard). My activity stays in portrait mode, but seems to get restarted and looses all its states. This does not happen with the hero version. My application is quite big so i dont want it to restart and loose all its states when the keyboard is opened.
View 1 Replies
May 14, 2009
I have created an activity for my game which handles all orientation changes by itself and has a fixed "portrait" layout. Actually it uses the accelerometer and is rendered using 2D canvas methods. If the level has been completed I show up a highscore dialog in which the user can enter his name. The dialog is floating above the underlying level screen which gets blurred out nicely. This generally works.
Problem is that the dialog does not get rotated if the orientation of the phone changes. So even if the keyboard is exposed the dialog is shown in portrait mode instead of landscape. I have tried to use an activity with dialog theme instead but the behavior didn't change. After several tries it seems that I have found the reason for this: Once there's an activity with fixed orientation in the activity stack then all subsequent activities keep this orientation, too. They will not react on orientation changes anymore (e.g. if the keyboard gets exposed).
After upgrading to 1.5 SDK the described behavior changed a little bit. Now at subactivities indead react on orientation changes like expected. However, the need to have an opaque background! That means that neither dialogs nor activities with dialog theme will work. Those will stick with the orientation of the underlaying activity. So my workaround is to first start a sub-activity with an opaque black background. This activity then shows my highscore dialog on top. It looks quite okay but I wonder if there's a better solution? Is it possible to show a dialog above a fixed portrait or landscape activity which automatically adapts to orientation changes?
View 3 Replies
View Related
Jan 14, 2010
Users of my application will engage a feature that temporarily uses the accelerometer. I would like to disable support for orientation changes while this feature is active. Is there an API for this?
View 2 Replies
View Related
Jul 30, 2009
I have a notification that starts my activity and passes a messages using the intent's putExtra() function. The message is then displayed to the user in the activity's onCreate function. When the application is restarted due to a orientation change, the message is shown again as it is still in the intent's bundled data.
How can I remove the extra data?
I tried the following:
Bundle bundle = getIntent().getExtras();
if (bundle.getBoolean("showMessage")) {
// ... show message that is in bundle.getString("message")
// remove message
bundle.remove("showMessage");
}
But the message will still be shown after the orientation changed, seems like the intent used is not the one I changed, but the original one. The only workaround I found is to save the showMessage additionally in onSaveInstanceState(). Is there another way? Or is this the way to go?
View 2 Replies
View Related
Aug 31, 2010
My main activity has some code that makes some database changes that should not be interrupted. I'm doing the heavy lifting in another thread, and using a progress dialog which I set as non-cancellable. However, I noticed that if I rotate my phone it restarts the activity which is REALLY bad for the process that was running, and I get a Force Close.
What I want to do is programatically disable screen orientation changes until my process completes, at which time orientation changes are enabled.
View 3 Replies
View Related
Sep 21, 2010
Is there a way to enable / disable orientation changes at runtime?
i know you can force a screen orientation in your manifest using android:screenOrientation="portrait" or ="landscape"
but I would like a way to enable / disable it at runtime.
View 2 Replies
View Related
Jul 22, 2010
I have a widget which has say, a dimension of 294*72(portrait). But when the orientation is changed, I need to change this dimension of the widget to another dimension which would look good on the landscape orientation.
View 4 Replies
View Related
May 26, 2010
Can I temporarily disable automatic orientation changes in my Activity? I want to do this when my app does some background internet communication.
View 1 Replies
View Related
Jun 8, 2010
I have an image set as my background and when it is vertical, the image looks fine. However, when the orentation is changed, the image get streched out. If there a way that I can change the image based on the orentation of the device?
View 4 Replies
View Related
Mar 25, 2009
I am building a AlertDialog in java code, so by default it is portrait but I want to show it in landscape orientation. How to do it in Java code?
View 2 Replies
View Related
Oct 8, 2009
I notice when using the emulator that when the screen is flipped, I get a following logcat message:
INFO/WindowManager(589): onOrientationChanged, rotation changed to 1
How can I catch this in the code? I want to know whenever the orientation changes. I assume I have to set a listener, but I can't find an example anywhere.
View 6 Replies
View Related
Mar 5, 2010
I'm doing an APP that shows some dialogs. Those dialogs are Alert dialogs, and when they are being showed if I change the orientation of the mobile I lost them...they are not being kept on the screen.
View 13 Replies
View Related
Oct 1, 2009
Do Views know changes in orientation? In my case, I create popups from TextView and need to know when the orientation changes(porttrait<-- >landscape). I cannot depend on activity's onOrientationChange.
View 2 Replies
View Related
Feb 11, 2009
I am making an Android app which is currently coming along nicely - I've hit upon a couple of stumbling blocks.
1) How do I stop the screen from going dim/off and the phone locking while the application is running?
2) Can I force the phone to enter landscape mode on running my application?
View 2 Replies
View Related
Jul 1, 2009
My app *sometimes* when orientation change, leaks Activities (getInstanceCount() increases from time to time) and i cannot figure out where references to my Activity or rather Context are kept - tried to use jhat but it couldn't help me much.
what is strange: it doesn't always happen on orientation change, so its even harder to fix.
btw when doing normal app life cycle - start, do something, exit - everything is ok - getInstanceCount() always returns 1.
View 5 Replies
View Related
Apr 28, 2010
I have an activity that checks stuffs online when it's created (is the GPS on and if not it asks if the user wants to turn it on).
The problem I'm having is that it is also doing it everytime I change the orientation of the screen.
I've read some comments on onConfigurationChanged() but is there a better way to be sure I'm checking the GPS only when the activity is first created?
View 4 Replies
View Related
Jun 23, 2010
built a simple app that displays an alertDialog with two buttons.The problem is it's not getting dismissed when i change orientation. After change i get a leak warning on debugger and the dialog appears twice(pressing back hides the first dialog, only a second back dismisses it completely).
View 7 Replies
View Related
Nov 6, 2010
I want to know how to change the orientation of my layout inside of eclipse but when I click the "layout" button it still shows it as a vertical layout.
View 4 Replies
View Related
Nov 6, 2010
I want to know how to change the orientation of my layout inside of eclipse.
View 1 Replies
View Related
Mar 17, 2009
consider the simple layout:
CODE:..................
View 9 Replies
View Related
Dec 29, 2009
I am developing a photo frame widget, all works except on an orientation change to landscape mode my appwidget doesn't display correctly as I have it set to portrait dimensions and it is too large for the display. I would like to run some code to resize the image so that everything displays correctly and it uses all the space that I allot. What is the correct way to do this? I can think of 2 methods however both seem inefficient. The first would be to register a broadcast reciever to take orientation changes, however I don't want to redo my appwidget everytime the phone is turned on its side as the majority of the time the homescreen is not showing when the orientation is changed (ie other apps are used, and I don't need my code running in the background). I only need it to run when the home screen is shown. The second would be to setup a service to manage my appwidget but that also seems inefficient to be always running in the background.
View 10 Replies
View Related
Apr 24, 2009
Is it possible to have a user choose how an app should respond to orientation changes? I have it set to android:screenOrientation="sensor" in the manifest but I would like users to be able to turn this on and off or set landscape or portrait orientation permanently.
View 5 Replies
View Related
Nov 2, 2010
When I change orientation application restarts and I lost my current data.. I am using activity group which contain lots of activities when i change orientation application restarts from main activity. is it possible to avoid this application restart on orientation change?
View 4 Replies
View Related
May 31, 2009
Some of the content in my widget is based on custom drawing routines. is there any event i can listen for so i redraw and update this custom area when the orientation changes? currently my widget looks pretty screwed until the next widget update is requested.
View 3 Replies
View Related
Apr 15, 2010
Well, preventing an orientation change is easy. But what about doing it at run time.
Say, I have an activity which supports orientation change in normal situations. It has say three Edit Texts.
There's also a button, which when clicked would do some processing in a thread while showing a ProgressDialog which is not cancellable.
Ok, so till the user hits the Button, I want the activity to be able to adapt the orientation changes. I have two layouts files for each orientation with different layout schemes.
What I want is this. Once the user clicks on the button, and the ProgressDialog is showing, I don't want the activity now to be re- created again when the orientation changes. So, before showing the ProgressDialog, is there any way to tell the Activity not to handle Orientation change?
Also, once the process is complete, and the ProgressDialog is removed, I want the Activity again to be able to handle orientation changes.
View 6 Replies
View Related
Aug 30, 2009
In the following sequence of events:
1. Start a new thread (as a result of a button click - or similar).
2. User changes the screen orientation (causing the Activity that started the thread to be destroyed).
3. Thread finishes, and wants to do some dialog (or any UI) work. However, doing a showDialog, dismissDialog, ... will crash, as the thread it still referring to the old Activity.
This can be solved by updating the data in the thread to refer to the new Activity upon a screen orientation change.
However, couldn't the Android framework just forward any requests from a destroyed activity, to the newly created Activity, saving us developers of handling it ourselves?
View 24 Replies
View Related
Feb 1, 2010
I have EditText in my application. While entering the text i am changing the portrait mode to landscape mode. Not the entered text is resetting. how do i handle this? Like if i change the orientation what ever entered text should be remain as it is.
View 2 Replies
View Related
Jun 17, 2009
Is the view aware of the orientation change in order to return updated size after a change in orientation? I'm handling the orientation myself (android:configChanges="orientation|keyboardHidden"). Does it means that I have to take into account the orientation state when querying for view.getHeight()? The view returns the same value as before the orientation change. It this the normal behavior or I should "notify" somehow the view to "refresh" its size.
View 2 Replies
View Related
Oct 12, 2010
I was looking at the way Android handles orientation change for my application (I discovered that it restarts the mainactivity on orientation change :| ). I've seen that you can ovveride the method protected void onSaveInstanceState(Bundle outState)to save stuff, then have the in onStart. The problem is that I've my view with custom objects and a listview using a custom adapter... Everything is in a ArrayList of these objects, but I've noticed that you can't put arbitrary objects in the bundle! So how do I save the state?
View 2 Replies
View Related
Sep 12, 2010
The CSS for my webapp gets completely misaligned when the mobile device is rotated to landscape (target devices are iphone and android). I tried using the javascript solution explained here in order to get my app to switch between a portrait.css and a landscape.css file on orientation change, but that still didn't work. It even messed up the portrait.css once they were both posted to the live server (although it worked on my local machine).The url for the app is http://mobile.geekstats.com/ Does anyone know how I can fix the landscape css?
View 1 Replies
View Related