Android :: Changing Orientation Resets Activity
Jul 7, 2009
I finally got to the point where I was ready to deploy my app to my G1 and test it out and the first thing I noticed was that when I change my phone to landscape view my main activity restarts and resets all of my variables to their default settings. How can I avoid this?
View 7 Replies
Apr 7, 2010
I have Activity with ListView inside it and in the onCreate method of the Activity I have code for populating the Data of the ListView this Data is a server based and so populating includes calling Network URLs. I have the ArrayAdapter of the ListView in the Same Activity Class.
Now the Issue I'am facing is that, in Rest all scenarios my Activity is behaving in a proper way but when the Orientation [ Portrait to Landscaped or other way round] is taking place the Data is Getting lost and Newer Data calls are Required to Populate the Same Old Data now this is something that is not intended out the code how should I deal with it.
View 4 Replies
View Related
May 5, 2010
So I am making a basic chess app to play around with some various elements of android programming and so far I am learning a lot, but this time I am lost. When the orientation of the emulator changes the activity gets reset. Based on my research the same thing will happen anytime the application is paused/interrupted, ie. keyboard change, phone call, hitting the home key etc. Obviously, it is not viable to have a chess game constantly reset, so once again I find myself needing to learn how to fix this problem.
My research brings up a few main things, overriding the onPaused method in my Activity, listening for Orientation, Keyboard changes in my manifest (via android:configChanges), using Parcelables, or Serialization. I have looked up a lot of sample code using Pacelables, but to be honest it is too confusing. Maybe coming back tomorrow with fresh eyes will be beneficial, but right now the more I look at Parcelables the less sense it makes.
My application utilizes a Board object, which has 64 Cell Objects(in an 8x8 2D array), and each cell has a Piece Object, either an actual piece or null if the space is empty. Assuming that I use either Parcelable or Serialization I am assuming that I would have to Parcelize or Serialize each class, Board, Cell, and Piece. First and foremost, is Parcelable or Serialization even the right thing to be looking at for this problem? If so is either Parcelable or Serializable preferred for this? And am I correct in assuming that each of the three objects would have to be Parceled/Serialized? Finally, does anybody have a link to a simple to understand Parcelable tutorial? Anything to help me understand, and stop further headaches down the road when my application expands even further.
View 6 Replies
View Related
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 6, 2014
Specifications:
Sony Xperia V (LT25i)
Official Android 4.1.2 9.1.A.1.145
Problem: I have two batteries, default one and Mugen one. Every time I change a battery the phone system time resets.
What I have tried to do: Set "Automatic date & time" and "Automatic time zone" on - No luck. Restar after set on -
Install different NTP server synchronizing app. I am in china, so it could not connect to the server and I get error every time, even after change to chinese NTP server - Still no luck...
Install different GPS synchonizing app, sometimes it work sometimes not and it takes too long to synchronize.
View 3 Replies
View Related
Jan 21, 2010
When views with different type have same id and screen orientation changes,
either java.lang.ClassCastException: android.view.AbsSavedState$1 or java.lang.IllegalArgumentException: Wrong state class -- expecting View State will occur. (depends on the view's order)
Because View.dispatchRestoreInstanceState() checks id only.
You may wonder why anyone would make views with different type to have same id.
But it can happen when you use tab activity.
Imagine you have tab activity with two children activity.
Tab1 is ListActivity and Tab2 is ExpandableListActivity.
Both activity have id of "@android:id/list" but the type of view is different.
This means we cannot use ListActivity & ExpandableListActivit at the same in one tab activity.
View 4 Replies
View Related
Nov 2, 2010
I have a TabActivity, and each Tab corresponds to its own Activity. In one of them, in the onCreate method, I use startActivityForResult to show a dialog (specifically, Bump's BumpAPI activity).
code:...............
The problem is that when the screen orientation changes, it tries to create the tab's activity again which makes another BumpAPI dialog, resulting in multiple stacked on top of each other. Do I have a hook into the started activity to cancel the previous one when the orientation changes?
A workaround seems to be to add a button that when clicked, starts the second activity, but that adds an unnecessary step.
Also, I can't fix the screen orientation for the entire tabActivity because some of them require typing and users may want to use their physical keyboards.
View 1 Replies
View Related
Apr 26, 2010
I have a widget set up and it displays properly in both portrait and landscape when added to each. But when I change orientation it has the problem "Problem Loading Widget". I delete this, re-add the widget, and it displays correctly. Thus, my widget can support both portrait and landscape but it doesn't survive an orientation switch. What am I missing? Do I need to redraw the widget when orientation is changed? Doesn't it do this automatically? Do I need to call onUpdate() somehow?
View 2 Replies
View Related
May 8, 2009
I get an OutOfMemoryError every time i change the screen orientation and I am having a hard time finding the mistake...
The Activitie's view consists of an ImageView, two Buttons and a Spinner. I don't have static variables and can't imagine where i could leak a context.
Most of the times, the exception is thrown at setContentView (R.layout.upload); sometimes it goes fine until imgUpload.setImageURI(imageURI);
The images i am displaying are form the G1's camera, so about 500kb and 2048x1536pixels
Here is some code:
CODE:..................
View 3 Replies
View Related
May 13, 2010
I am having an application showing ListItems and Dialog boxes in it.. I want that when i change the orientation from Portrait to landscape mode, i need to maintain the state of the application .. I have seperate XMLs for landscape and portrait mode..
View 11 Replies
View Related
Jul 27, 2010
I get a leaked window when I have a submenu visible on the screen and I rotate the screen. If it would be a Dialog I colud call dismiss() in the onStop() before to change the orientation, but with a SubMenu how do I can solve it?
View 5 Replies
View Related
Jul 8, 2009
I have a widget , thats working just fine in a particular orientation, but the moment i change the orientation to landscape/portrait, the widget is not able to launch. I have one layout and one layout-land folder in res directory.The problem is that the widget created in landscape mode is not opening in portrait mode and vice-versa.
View 4 Replies
View Related
May 25, 2010
While I tested my application on an Android Device turning my Android phone from landscape to portrait, results in all the list items in my list view are disappearing.
View 2 Replies
View Related
Jan 18, 2012
I am working on a game for android at the moment, and was wondering how i would change the screen depending on orientation.
So if the user turned the phone horizontally then the app would be viewed horizontally if you know what i mean
Also how would i make a timer, so if a button were pressed, how would i say stop for 2 seconds and then go to link?
View 3 Replies
View Related
Sep 16, 2009
Just started testing my games in 1.6 and the first thing I notice is that on the landscape ones, the dpad up/down/left/right orientation doesn't switch 90 degrees like it did on all emulators before.
The device trackball/dpad will still change with orientation (right becomes up on landscape, etc..), right?
View 9 Replies
View Related
Jul 16, 2010
I'm not sure If I did something to my phone after hours and hours of playing and installing/uninstalling ... but my screen orientation no longer changes to landscape when I rotate the phone!
View 1 Replies
View Related
Oct 3, 2009
I've seen on YouTube quite nice animation as browser changes from portrait to landscape. I don't get this, even after selecting 'show animation' in settings. How can I get this?
View 3 Replies
View Related
Jul 20, 2010
I am in my fourth activity and I want to come back to the first activity directly (without closing the second and third activity). How to change to the activity directly?
View 1 Replies
View Related
Aug 9, 2010
I am writing an activity, that loads data from a server and displays it as a list using ArrayAdapter. For that I'm showing a progress dialog i.e loading, while it loads all data from the server. Then i dismiss the dialog in a handler. My problem is that when ever i change the orientation, the progress dialog is again shown, which is not needed, because all the data is displayed already?
View 1 Replies
View Related
Sep 20, 2010
How does my android activity know (is there a callback) when there is a change in screen orientation?
View 1 Replies
View Related
Aug 16, 2010
I know on screen orientation changes activity restarted, but suppose i don't want to restart the activity then what should I do? I had tried it by adding in manifest.xml. android:configChanges="keyboardHidden|orientation"
and override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); }
But still activity restarted each time when I change screen orientation.
View 17 Replies
View Related
Jun 3, 2010
I am having an interesting problem and would appreciate any advice. My app uses WebView as its primary view. Using a javascript hook, it can launch the camera so the user can take a picture. The camera is launched using: Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
When the camera starts, it makes sense to use landscape mode, so the user naturally turns the phone on its side. After the user takes a picture, control returns to my launching Activity (actually, my Acitivity gets restarted because it usually gets destroyed to free up memory for the camera on my Moto Droid). When my WebView gets recreated, I restore its state from the Bundle I saved in onSaveInstanceState().
Now everything looks ok, except the phone is still in landscape mode. However, when the user turns the phone upright bringing back into portrait mode, my WebView takes up only half of the screen. Somewhere along the way, the scale of my WebView got lost. This seems like such a minor issue, but it is driving me crazy.
Does anyone have an idea why this might be happening? What is the correct way to preserve the scale of my WebView? I am hesitant to hard code any scale factors because what looks good on my device may not be the same for another.
View 8 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
Nov 24, 2010
It is possible to set the orientation of an activity in the manifest file. but is it also possible to do it from code? if so, how?
View 2 Replies
View Related
May 6, 2010
I m currently working on landscape mode for android app in which i want to know how to maintain the state of the activity and views displayed on orientation change i.e from portrait mode to landscape mode ?
View 3 Replies
View Related
Apr 5, 2010
I am working on a MVC implementation for Android (to be subsequently hosted on SF and/or GC).
It works like this:
Activity (View) <=> Application (Controller) <=> Data (Model) <=> Persistence (DB/Network etc)
The scenario is:
1. Activity launch (main/launcher)
2. Notifies Application about performing a data transaction
3. Upon receipt of data response, controller devices which Activity to launch (or update existing)
4. Application has overridden the method onConfigurationChange
Problem: When the orientation is changed, the Application is notified about onConfigurationChange but:
a) The "current" activity is Destroyed and recreated -- which is fine to some extent b) The new instance which is created is automatically => onCreate, onPause, onStop, onDestroy.... now that's catastrophic.
View 4 Replies
View Related
Sep 11, 2010
My MainActivity (the one that is started by the android application) is a TabActivity which contains several tabs (which are implemented as activities as well). In a certain tab/activity I want to prevent the change of orientation/rotation when the phone is turned. What is the easiest way to achieve this?
View 2 Replies
View Related
Apr 6, 2010
i've developed an android app that's fetches an xml file and displays this data via several markers on the map. This works fine so far. The problem right now is that when i switch the orientation of the phone (portrait->landscape or vice versa) the markers disappear for a small moment, the xml processing is started again and then they reappear. Is there a way to prevent this re-loading of the file? It only takes about 2-3 seconds.
View 2 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 7, 2010
I have an Android Activity with a RelativeLayout and I have implemented the following method to prevent the activity from being recreated on change of Orientation:
CODE:..............
I am obviously not doing anything in this method, but it worked perfect when using a LinearLayout. Now however, using RelativeLayout, my layout is all messed up when changing to landscape orientation.
What is the most efficient way to have the screen redraw correctly without having the activity restarted again with a call to onCreate?
View 2 Replies
View Related