Android :: Save And Restore A ButtonText When Screen Orientation Is Switched
Nov 7, 2010
As usual in android, each time the screen is flipped to portrait/landscape mode an Activity runs through life-cycle from onSaveInstanceState to onDestroy and then is recreated.In my Activity there's a ButtonText which can be changed by the user. It's reseted to the initial state, but I have to save the last state somehow. How can I achieve that, will I have to override onSaveInstanceState? Can someone show an example?
View 1 Replies
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
Jul 2, 2010
I love the laucher pro home screen however i not have acces to my HTC widgets. i really just want the 9 person favorite widget, htc clock, and the radio widgets (4g, wifi, bluetooh, and gps) any way i can add this?
View 15 Replies
View Related
Oct 20, 2009
I have a custom View, what is the proper way of saving / restoring it's state after orientation change. I know I should implement onSaveStateInstatnce() and onRestoreInstanceState() methods, but how exactly (with which argumets) and when I should call them?
View 4 Replies
View Related
Oct 25, 2012
I am building an application in which I have to use canvas. I have to save the image into same dimension no matter what is the orientation.
View 3 Replies
View Related
Feb 1, 2010
I have a MapActivity that contains a MapView with some custom controls, state information, and an ItemizedOverlay composed by some locations that I draw using the default approach (using populate(), super.draw() and createItem()) and by some lines that I draw in the overrided draw() method.
So, when the activity is paused, I have to save:
Some state information
The ItemizedOverlay
[Maybe more Overlays in the future.]
I'm saving the state information as usual, putting them in the bundle. I'm thinking in doing the same with the Overlays, implementing Parcelablein each one of the OverlayItems and so, but I don't know if there is a better way to store the complete state of the MapViews.
The information depends on remote requests that I don't want to repeat each time the activity is paused. Any recommendation?
View 2 Replies
View Related
Jun 1, 2009
I have an application which uses a cookie to tie a user to a session on my server.
Is there a simple way to save and restore this cookie to a SQLiteDatabase so that the user does not have to reacquire the cookie every time the app starts?
View 4 Replies
View Related
Nov 7, 2010
I got my phone rooted and got velocity on the phone, but i noticed some issues within the first few days. the 50% bug seemed to get worse, before i could do the airplane thing and it would be good for about a week, now when i do it it will last less than a day and i cant get more than a day of battery life with not using my phone much at all, before i could get about 2 days with regular use.
when i slide the keyboard out an the screen switched to landscape the all the icons and widgets would disapear then re-appear about 15 seconds later, it does the same thing when closing the keyboard. some times it gets stuck and just flashes the screen with no icon or wigets and the only way i can fix it is rebooting the phone.
the flashlight app that comes with it works perfectly but when i close the app the notification lights keeps flashing and changing colors it wont stop untill i reboot the phone. everything else seems to be working fine for me. p.s. the ad blocking in the apps is a very nice addon
View 12 Replies
View Related
Sep 27, 2009
This is with the 1.6 & 1.5 SDKs, not tried earlier ones. When you switch from portrait to landscape the onSaveInstanceState()/ onRestoreInstanceState() pair are called once, but when going back from landscape to portrait they are called twice, unless I've missed something. To test, see the log after creating a default Hello World app and change the main class like this: code...
View 4 Replies
View Related
Feb 19, 2010
In Android, you need to implement the following Activity methods so your application can be restored to its previous state if the OS decides to destroy then recreate your activity:
public void onSaveInstanceState(Bundle savedInstanceState)
public void onRestoreInstanceState(Bundle savedInstanceState)
The examples I've seen of implementing these methods is to use put/getBoolean, put/getInt etc. on the Bundle object (i.e. primitive objects only) to save the application state. This seems hugely error prone way to save your state for a start and I cannot see how this scales to storing complex objects without writing lots of code.
What options do I have for storing/restoring state in a robust and easy to implement fashion?
In case it's important, my application (a game) needs to store about 50 objects, which each store maybe 5 float variables and some store references to other objects. I don't particularly want to have to write save/restore methods for every class and subclass (maybe about 15 of these) I use. It would be ideal if I could just stick all my state relevant objects in an object called "state" and then just call save/load on "state" to handle everything.
Is using Java serialization an option? I've heard it's very slow, but is that a problem for save/restoring? Could I just write my data to the SD card? To a database?
View 1 Replies
View Related
Oct 16, 2010
How do i reinstall saved apps and settings when i have flashed a new rom .Iassume it is possible .
View 2 Replies
View Related
Sep 10, 2010
I'm considering trying one of the ROMs available here for my behold 2.Will I lose all the apps and other user data I have?If so, is there a way to save the apps/information and then restore it after the flash ?I have a few paid apps in particular that I'd prefer not to lose.
View 3 Replies
View Related
Dec 16, 2009
Is it possible to check the screen orientation (I mean whether the screen in landscape or portrait mode) while the outgoing call is going on.If it possible please suggest me how to achieve that.
View 2 Replies
View Related
May 29, 2010
is it possible to manually rotate the screen or fix the current screen orientation (with a key/button)? because it really annoys me having taken portrait pictures that cannot be viewed (with the media gallery application) in a portrait fashion on the milestone. this is because it always rotates the portrait picture back to landscape when rotating the milestone from landscape to portrait. right now there is no way of properly viewing portrait pictures on the milestone other than tilting your head (holding the milestone landscape and tilting your head along).this cannot be the way it was intended to be, right? or do I have to get a different viewing software which allows you to choose screen orientation? is there such an app?
View 1 Replies
View Related
Mar 18, 2009
I would a Tab (in a TabHost) to have a Landscape orientation while the activity with the TabHost is in Portrait orientation, is that possible (if so how)? I tried setting the orientation of the Activity displayed in the tab in the Manifest but it didn't work.
View 7 Replies
View Related
Jan 19, 2012
I was wondering if there was any java code that will allow you to make sure each window in your app stays in portrait despite the user flipping the phone to landscape. I already tried inserting android:screenOrientation="portrait" into both my android manifest and into every single XML file I had but unfortunately only some stayed in portrait and others still flipped to landscape.
View 3 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
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 6, 2010
My project is working fine when i hold my HTC device vertical.But the moment i rotate my screen 90degrees , it throws a force close error.Starts all over again, runs fine until i again change the orientation.How do i handle it ?
View 1 Replies
View Related
Jul 2, 2010
I simply want to do code...
The problem is - getRequestedOrientation always returns -1. Any suggestions?
View 2 Replies
View Related
Sep 23, 2010
I have a series of live wallpapers out and one major sticking point I have with a certain set is that when devices switch to Landscape, the wallpaper, which in most cases is an image designed to fit the screen in portrait mode, appears off center. What is the conventional way to detect the shift from portrait to landscape?
View 2 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
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
Mar 2, 2010
Please tell me how i can stop the change in orientation of application when device rotate. How i can control the accelerometer.
View 5 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
Nov 18, 2010
I snap a photo, and it gets placed onto an ImageView. When the user sees the page where the Image View is, and I turn the phone sideways where the orientation is horizontal, the app immediately returns to the app's main screen.
View 1 Replies
View Related
Sep 24, 2010
We currently use Activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_x) to set (and 'freeze') the orientation of our app. Froyo now supports two landscape modes tho and we'd like to allow our users to orient the app to 'landscape right' ... ie, the orientation obtained by turning a device naturally oriented to Portrait 90 degrees clock wise.
View 3 Replies
View Related
Aug 27, 2009
I want my Activity to be always in portrait mode and I do NOT want the onDestroy() method to be called. There are some interesting articles about that at: http://www.androidguys.com/2008/11/24/rotational-forces-part-four/
The solution seems to be: In AndroidManifest.xml:
CODE:...............
I've tried it and it seems to work. Is there any other alternative or is it the correct solution?
View 7 Replies
View Related
Apr 23, 2010
Specifically, I need a way of _not_ performing the onPause functionality I've implemented when it occurs because of a change in screen orientation.
View 9 Replies
View Related
Aug 30, 2010
I am trying to display an image from a URL, which may be larger than the screen dimensions. I have it kind of working, but I would like it to scale to fit the screen, and I also have problems when the screen orientation changes. The image is tiny, and I would like it to scale its width to the screen as well. (In both cases, I would like the image to fill the screen width with scrollbars (if necessary for height).
Here is my ImageView:
CODE:..............
Here is the java code which loads the image: (some error handling code removed for simplicity)
CODE:.........
I have tried different settings for android:scaleType. I'm sorry if this question has been asked before. I've gone through a number of tutorials on the subject, but they don't seem to work for me. Not sure if it has anything to do with the way the image is loaded. (from the web instead of a local resource)
Another issue is that sometimes the image doesn't even load. There are no runtime errors, I just get nothing in the ImageView.
View 1 Replies
View Related