Android :: Saving And Restoring State?

Jul 15, 2010

I have searched through this and a few other sites for the answer, but I have been unable to find it. I am trying to save a boolean and an int using onSaveInstanceState and onRestoreInstanceState, but I can't seem to get it to work. It doesn't crash or anything, but it either isn't saving it or it isn't restoring it, or I am stupid and have no idea what I am doing.

Here is what I have for my activity, do I need to have it in my onCreate somewhere or something?

CODE:..............

I tried putting stuff in the onStop, but it crashes, which is why its empty, in case that matters, thanks in advance

Android :: Saving and restoring state?


Android :: CheckBox -- Restoring State After Screen Rotation

Mar 24, 2010

I have come across some very unexpected (and incredibly frustrating) functionality while trying to restore the state of a list of CheckBoxes after a screen rotation. I figured I first would try to give a textual explanation without the code, in case someone is able to determine a solution without all the gory details. If anyone needs more details I can post the code.

I have a scrolling list of complex Views that contain CheckBoxes. I have been unsuccessful in restoring the state of these check boxes after a screen rotation. I have implemented onSaveInstanceState and have successfully transfered the list of selected check boxes to the onCreate method. This is handled by passing a long[] of database ids to the Bundle.

In onCreate() I check the Bundle for the array of ids. If the array is there I use it to determine which check boxes to check when the list is being built. I have created a number of test methods and have confirmed that the check boxes are being set correctly, based on the id array. As a last check I am checking the states of all check boxes at the very end of onCreate(). Everything looks good... unless I rotate the screen.

When I rotate the screen, one of two things happens: 1) If any number of the check boxes are selected, except for the last one, all check boxes are off after a rotation. 2) If the last check box is checked before rotation, then all check boxes are checked after rotation.

Like I said, I check the state of the boxes at the very end of my onCreate(). The thing is, the state of the boxes at the end of onCreate is correct based on what I selected before the rotation. However, the state of the boxes on the screen does not reflect this.

In addition, I have implemented each check box's setOnCheckChangedListener() and I have confirmed that my check boxes' state's are being altered after my onCreate method returns.

Why would the state of my check boxes change after my onCreate method returns?

I have been trying to degub this for a couple days now. After I found that my check boxes were apparently changing somewhere outside my own code I figured it was time to ask around.

View 4 Replies View Related

Android :: Confusion With Activity Stack And Restoring State / Whats Wrong?

Jan 11, 2010

I have a start activity page for my game (which is the root activity for my app) that just lists "Play", "Help", and "About" TextViews on the screen. Each TextView has a click listener which start the appropriate Activity for each. The GameActivity (started with explicit intent from clicking "Play") has onSaveInstanceState implemented to save state of the game. Its onCreate checks for non- null Bundle to restore this state. My problem is this:

1. Turn on Phone/Emulator 2. start my game with icon in launcher 3. Start page is displayed 4. click "Play" to start my GameActivity 5. play game for a few seconds 6. click home 7. state is saved (proven with debugger calling onSaveInstanceState) 8. start my game with the icon in launcher 9. start page is displayed

I was under the impression that by clicking the app icon from the launcher that my existing task activity stack would be restored with my GameActivity being on top and its onCreate being called for me to restore the state I saved. Instead I am getting a brand new instance of my start page. Also, if I long press home and choose my running game icon, then my game comes back exactly as I left it. However, this apparently is NOT using my onCreate restore state logic as onCreate is never called.

All of the documentation seems to say that the entire stack of activities will be restored when clicking the application icon from the launcher, but I just get a fresh instance. What might I be doing wrong?

View 2 Replies View Related

Android :: Saving Application State?

Jan 11, 2010

I understand how to save an application's state by using SharedPreferences, onSavedInstanceState() & onRestoreInstanceState(), etc as outlined in a similar post ( http://stackoverflow.com/questions/151777/how-do-i-save-an-android-applications-state ), but how do I save the last activity?

To be more specific, my application starts up and goes to a login screen. Once a user logs in and navigates through several activities, lets say he or she leaves the app using the home button or in some other way. Next time the user starts the app, it will go back to the login screen and do a login again. Instead, I want the app to start up and go to the last activity that was on top of the stack when the user left the app in the previous session.

How is the last activity saved so that it can be restored on app startup?

View 3 Replies View Related

Android :: Saving State Of An Application?

Jul 5, 2010

Which of the following is/are appropriate for saving the state of an Android application?

a. Activity.onFreeze()
b. Activity.onPause()
c. Activity.onStop()
d. Activity.onDestroy()
e. Activity.onFinish()

View 2 Replies View Related

Android :: Saving State Of ArrayList Of Custom Objects

Aug 12, 2010

I have a member variable in my Activity which is an ArrayList. The objects populating this Array List are objects I have defined called Rating Item. Rating Item has several member vars like rating, comment, ID, etc. I would like to save this Array List in onSaveInstanceState so it can be repopulated from onRestoreInstanceState. What is the best way to do this? I've never saved the state of an object of this complexity.

View 2 Replies View Related

Android :: Saving Dialog State - OnStop Not Getting Called?

Jul 14, 2009

I'm saving the state of my activities for orientation change support, it works well. Sometimes I have a dialog open though and need to save its state as well. My dialog's onStop() method doesn't seem to get called when I change orientation. Where would get notified inside the Dialog that we're being destroyed, so I can save its state?

View 3 Replies View Related

Android :: Saving Cursor State With Activity Instance?

Apr 27, 2010

I've got an android app that pulls a random 20 questions (rows) as a cursor from a SQLite DB and loops through all the questions to ask the user all 20 questions.

Is there some way to save the cursor's state/location when the activity is paused or stopped so that when the activity resumes the cursor is restored and in the same position as it was when the activity was paused/stopped?

View 1 Replies View Related

Android :: Saving An ArrayList (String) State In SQLite Database

Jul 9, 2010

I'm working on a android application that will display Strings to the user, and the user then has the option to add one to a favorite list. I have searched and searched and cannot find the proper way of doing this. I did get one open source project, everything worked until the user removed a favorite. The database would clear the row of data, but when a new row is added, it would behave as if the deleted row still had data, leaving blanks in the favorite list.

This is my insert method
public long insertString(String newString)
ContentValues newStringValue = new ContentValues();
newStringValue.put(KEY_STRING, newString);
return db.insert(DATABASE_TABLE, null, newStringValue);

The long returned will always increment even if i use the remove method:
public boolean removeString(long _rowIndex)
return db.delete(DATABASE_TABLE, KEY_ID + "=" + _rowIndex, null) > 0;

If I try to remove the third index, and the user removed a question at the third index, the method returns false, is there a way to completely remove all rows with no data?

View 2 Replies View Related

Android :: State Of Activity Saving When Home Button Pressed

Oct 24, 2009

I am having an issue related to home key . when i press home key all current activity gets hidden. but when i press the executable it again starts from the fisrt screen . I have overidden all methods nsaveInstaceState opPause onStop onResume

but there are still issues what is the right way to handle those conditions. When i am pressing home button i am storing the widgets state in database and when i again click the exectable i am checking the database state and starting the new Intent as saved when user presses the home button .Is it the right way to do that as i am facing the problem when user does the same and again presses the back button , there is already on intent available in stack of activity .

View 2 Replies View Related

Android :: Prevent Activity From Saving State When User Selects Back Button

May 2, 2010

I have an Activity with a list that is bound to a ListAdapter reading data into a ArrayList from a database. All is well when the data is first loaded. While the Activity is open and the list is being displayed it is possible and likely that the data in the database will be updated by a service but the list does not reflect the changes because the ArrayList does not know about the changes. If the Activity is no longer in the foreground as would be the case if the user goes to the home screen and then is brought back to the foreground I would like for the Activity to not display what it did prior but rather reload the data using the ListAdapter the view is bound to. I think something needs to call finish() but I am not sure what.

This is what I have in the Activity.

CODE:.......................

View 1 Replies View Related

Android :: Changing Displayed State Of Views Based On Parent ViewGroup's State

Aug 11, 2010

I have a compound UI component built up from a ViewGroup containing a number of TextView, ImageView etc. components. Many of these have StateListDrawables as their images/backgrounds. Is there any way of making them select from this drawable based on the state of the parent ViewGroup rather than the component itself? Ideally I want to be able to change the visual state of all children of the ViewGroup (text colour, image etc) based on the state of the ViewGroup, preferably without having to hook up complex logical code. This seems like a fairly common sort of requirement, so I was hoping it would be straightforward in Android - am I going to be disappointed?

View 1 Replies View Related

Android :: Phone State Listener State Transitions

Feb 8, 2009

I'm a little confused by what I'm seeing with regards to phone state transitions via the PhoneStateListener. When I receive a call, this is what happens: (call comes in) RINGING -> IDLE (I pick up) OFFHOOK (I hang up) IDLE It's that first transition from RINGING to IDLE without any interaction from me (not ending the call, not answering the call) that confuses me. Do I really have to implement an idle counter to know that an incoming call has really ended? Seems like the reported phone state represents some sort of phone state that isn't the obvious one.Is this a bug or am I just not in tune with the paradigm here?

View 2 Replies View Related

Android :: Apps Not Restoring From SD

Sep 9, 2010

After updating to 2.2 I put all of the apps I could from my phone to my SD card.I did this so I could back them up because my phone was having LED light issues so I got it replaced.So I took it to Verizon and they did a reset and it didn't help so they ordered a new phone for me.After this reset the apps from my SD card automatically "restored" (the phone used this word after it finished) my apps.Now, I have received the new phone and it is not automatically restoring this time.How can I get them to restore? When I go to applications in the settings menu it doesn't show any on the SD card.Also when I go to the market it only shows my purchased apps in the downloads section. Also my phone is NOT rooted.Any help is appreciated

View 21 Replies View Related

Android :: Restoring Data Backup Pro

Jul 31, 2010

HTC Holland advised me to do hard reset on my HTC Hero.They promised that I would get the android 2.1 update after reset (did not happen).Before the reset I downloaded MyBackup Pro first and I took the option of backing up my data and apps to my SD card.So now all my data and apps (including MyBackup) are zipped and stored on the SD.But how can I restore everything?I connected the phone to my laptop to get access to the memory card but I can't find out how to restore.How can I do this?

View 4 Replies View Related

Android :: Apps Trying To Automatically Restoring To Phone

Nov 18, 2010

I have been messing around with some ROMs on my Droid1, every time I flash a new rom it auto restores my apps. It hasn't done this at all until today. I have tried disabling it in my settings but it still doesn't stop. Also when I go into the downloads page in the market to cancel them, I can some of them but when I try to cancel the others if causes the market to force close. I would like to know if there is anyway to stop google from auto downloading them when I sign in? When I turned off the backup it said it would delete the info from googles servers, but it obviously has not lol because I have tried flashing the rom over again since then. I know most people would like this to happen, but I want a clean install.

View 2 Replies View Related

Android :: Backing Up & Restoring? Settings & Apps Etc?

Sep 6, 2010

I just got a HTC Desire and I love it so far, I've spent ages customising it, getting my contacts synced with facebook etc, favourites, bookmarks etc and downloading apps.Now I want to go about putting on a few different ROMs to see what I like. What is the best way to backup all my stuff so that when I do put on a fresh rom I can get all my stuff back as easily as possible?

View 1 Replies View Related

Android :: Restoring Applications On Replacement Phone?

Oct 15, 2010

I bought an Audubon Birds Field Guide app for my Droid X and installed it, in addition to a ton of other free apps. Unfortunately the Droid died and I got a new one from VZ. When I took the new DX to the VZ store to set it up the guy said I should be able to restore all the apps I had installed, including the one I bought, but none of them showed up on the phone. He was not really all that helpful and told me to contact Audubon about replacing the app. I just did that, but I am concerned that none of the apps I had already installed showed up on the new DX.

View 3 Replies View Related

Android : How Can I Get Clean Install Without Restoring Settings?

Aug 31, 2010

SO I sinstalled the CM 6.0.0 rom to check it out. I downloaded some apps and fiddled with some settings to see if I liked it, but decided to do a wipe before using it "for real". Unfortunately, I can't get it back to a clean install because it insists on restoring all of my previous settings and applications. Even ones I've uninstalled and gotten refunds for, no matter what settings I put in the Privacy section about backing up and restoring.

View 4 Replies View Related

General :: Quickly Restoring SMS From 2.3.5 Android Phone

Jan 10, 2013

I am trying to transfer about 14,000 SMS from an unrooted 2.3.5 Android to a rooted 4.2.1 Android phone.

MyBackup Pro backs them up quickly, but restores them at a rate of less than 1/second. Thus, I have been looking for another tool to back up with:

1. Titanium Backup: no, as the 2.3.5 phone is unrooted;

2. new Windows-based Ultimate Backup Tool: no, as it requires Android 4.0 or greater.

Any recommendations, other than running the restore tool all night? A tool that allowed me to back the SMS up in chronological blocks could be very useful.

View 2 Replies View Related

Android :: Restoring Active Activity While Resuming Application

Apr 7, 2009

I have two activities running: MainActivity and ChildActivity. Whenever the user clicks in the button in MainActivity, the ChildActivity is launched. What I want to do is this:When the active activity is the ChildActivity and the user clicks the home button then relaunch the application (like opening from the beginning), I want to see the ChildActivity instead of MainActivity that is launched. However; This is happening only when the user clicks from recent activities window. (the window opened when you long press the home button).I had some suggestions actually work arounds and I tried to manipulate onStart, onRestart, onResume, onStop, onDestroy events. But, they didn't fully solve the problem. There should be a smart way out there.

View 8 Replies View Related

Android :: Restoring Active Activity / While Resuming Application

Apr 7, 2009

I have two activities running: mainActivity and childActivity. Whenever the user clicks in the button in mainActivity, the childActivity is launched. What I want to do is this:When the active activity is the childActivity and the user clicks the home button then relaunch the application, I want to see the childActivity instead of mainActivity that is launched.I had some suggestions actually work arounds. I tried to manipulate onStart, onRestart, onResume, onStop, onDestroy events. But, they didn't fully solve the problem.

View 3 Replies View Related

Android :: How To Get Back To Droid 1.5 Version After Restoring To Default Factory

Jun 8, 2009

I've restored my android dev phone 1 to its default factory from the settings option. Now how can i get back to my android 1.5 version ? After restoring the appearing screen contains, Android logo followed bay "Welcome to Android Dev Phone 1, Tap the android to begin" message and two buttons one is for "Emergency dial" and the other one is for "change language" .

View 2 Replies View Related

HTC Incredible :: Titanium Not Restoring Sms / Mms

Sep 24, 2010

I rooted with Un revoked 3. I installed the Virtuous Rom 2.7 with Custom Kernel. I restored all apps from Titanium, but my MMS/SMS did not return. I had to restore from My Backup Pro. I would like to only keep one and use one Backup app. Is this normal for Titanium?

View 4 Replies View Related

HTC EVO 4G :: Restoring Data After Flashing Rom

Oct 20, 2010

Just flashed with Myn's Warm TwoPointTwo. Went very smoothly. I used Titanium back up (free) and Astro file manager to back everything up.Take note this is my second time flashing a rom. First time went fine. I have restored all data and apps. Everything is restored perfectly except my text messages which i need the most. Don't worry i did a nandroid back up before even flashing. I thinking i did all the restoring correct. Whats the deal lol? I would hate to restore back to the android back up and redo the whole flashing process again. Any alternatives?

View 2 Replies View Related

HTC EVO 4G :: Restoring Data From Diamond

Jun 10, 2010

I used PIM backup and backed up my stuff. How do I restore it into the evo?I also have another HTC diamond but the screen is bad.I'm able to connect it to a PC and can browse the folders. How can I restore my data to my other EVO (got 2 evos)

View 10 Replies View Related

Samsung Captivate :: Restoring To 2.1

Oct 5, 2010

I recently put froyo on my captivate and I'm wondering how to restore it to plain ol vanilla samsung 2.1
all of my stuff is backed up, just need to write and get back to2.1.

View 12 Replies View Related

HTC Desire :: Restoring With ROM Manager

Oct 1, 2010

I backed up a ROM using rom manager so i could try a new one, but if i want to restore the old one do i just do so right on top of the current one. i.e. no wiping required? Or should i wipe, get ROM manager and then restore?

View 2 Replies View Related

HTC Eris :: Restoring Apps

Oct 17, 2010

I have been playing with more roms the last few days and as such, i have been restoring my apps and setup quite frequently.I know that the "standard" advice has been to use titanium backup and backup and restore apps.When i started this latest round of "ROM exploration" i decided to try a different method. I have always been a fan of AppBrain and so i decided to try their Fast Web Installer to install apps based on what was in my previous app list.I like this method because it forces me to actually audit what apps I have on my phone and delete the ones that I no longer use or need.I know my settings aren't maintained but I don't find it too difficult to bring my phone back to standard working order.Just thought i might share my experiences with everyone especially the ones new to root.This forum has been extremely helpful to me in my rooting process so I want to give something back to it

View 2 Replies View Related

HTC Hero :: Restoring Everything After Flashing A New ROM

May 8, 2010

I've flashed SenseHero 2.1 & 2.2 over the last week or so, and as soon as SenseEspresso is ready I'm going to flash that one too. My question is, is there a quick way to get your phone back to the way you like it? I currently use mybackup pro & Titanium backup, and it takes me a fair chunk of time to reinstall all my apps and set up my homescreens.Any suggestions? What do y'all do?

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved