OK, I admit, I didn't do THAT thorough a search myself, but this issue of Alarms and orientation changes has been discussed so often before in this group, I can't help but think that the answer lies somewhere in the search results for "alarm orientation change".
I will leave it to you to decide which of these best answers your question(s). In the meantime, what I suggest to you is: I am not sure why you think using a TabHost will cause separate activities to be considered as one. A TabHost if, after all, just a container for a tabbed VIEW. Which Activities correspond to which Views depends entirely on you, depending on which choice you made of the two described in the Tab Tutorial, where it says: "You can implement your tab content in one of two ways: use the tabs to swap Views within the same Activity, or use the tabs to change between entirely separate activities. " But since they say that right after mentioning the need for TabHost, it should be pretty clear: the mere use of TabHost does not force that choice. On Feb 22, 8:54 am, DanielleM <[email protected]> wrote: > Hello all: > > So, I'm trying to write my activities in such a way as to save their > state if they ever get killed and restarted, and I've come across an > interesting dilemma when working with the AlarmManager. > > So the way my alarm Activity works is: > > 1. Set time button: launches time picker dialog that is set to the > current time (based on Calendar). Whatever time is chosen here becomes > the time the user wants the alarm to go off. > > 2. Radio buttons: let the user choose an audio file (in my case a > stream) that they want to play when the alarm goes off > > 3. Set Alarm button: calculates which day the alarm is for based on > what time was chosen (will either be later today or tomorrow) and then > calculates the offset in epoch time for the alarm manager. Next it > creates the intent and pending intent for use with the Alarm Manager. > Then it sets a flag (true) that the alarm was set and uses a Toast > message to tell the user the alarm is set and for what time (this > sounds like a lot and may need to go in a background task) > > 4. Cancel alarm button: cancels the alarm obviously :) > > So in my onSaveInstanceState method I'm saving all of the integers and > strings that I used for my calculations and the flag of whether or not > the alarm has been set. Then in the onCreate method I check to see if > the saved bundle is null, if not I get all my data back out. > > Then, I check to see if the alarmIsSet flag is true...if so, I go > ahead and re-create the intent and Pending intent and use the alarm > manager to set the alarm with my saved values....the only way the > alarmIsSet flag will be true is if the Set Alarm button was clicked > before the activity was destroyed and re-created...otherwise it will > always be false. > > So, on to my problem. If I set the time and set the alarm and then let > it sit...it works totally fine....It launches my activity that handles > the alarm (basically just plays one of the streams with a stop alarm > button). > > However, if I set up my time and click set alarm and then change the > orientation, or if i set the time, change the orientation and then set > the alarm...when it gets time for the alarm to go off it doesn't do > anything. Then I found the following messages in the LogCat: > > startActivity called from non-Activity context, forcing Intent > FLAG_ACTIVITY_NEW_TASK for Intent (name of my intent) > Activity pause timeout for HistoryRecord > Launch timeout has expired, giving up wake lock > > I don't understand how the first message can be possible...if the > activity is getting recreated after the orientation change, and the > intents are either created or re-created, how can it be a non- > activity? > > Now I plan to actually stop orientation changes from re-starting my > activities, but I wanted to be able to save the state in case the > activity gets killed by an incoming phone call or something else...so > I'm using the orientation change as a way to test my save state code. > > My app uses a tab layout with a tabhost...and I've noticed that it > doesn't matter what tab I'm on when I change the orientation, but all > of the activities are getting re-created...Also the back button will > close the app instead of going back to a previous tab (if there is > one) when you click it. > > Correct me if I'm wrong, but this leads me to believe that even though > all my tabs open separate activities, they are all considered one > activity because of the tab host. Unless the back button will back > track through tasks in which case this behavior is correct since all > my activities are all part of the same task. > > Anyway...any help that can be provided is much appreciated. > > Thanks, > DanielleM -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

