I've got an iPhone application, and I'd like it to reset its state every time the user leaves it, i.e. the home button is pressed. By "reset its state" I mean that the application should start as if it was started for the first time, and not resume from where the user left it. How can I implement this?
You may check this post, To restart the app from the home screen and not from the screen we left at
As you said, you theoretically could set that Boolean value in the info.plist file. However, you lose a lot of information like this. I recommend storing initial values in your app and load them every time te app starts. Tie your UI to those values.
Related
There are many view controllers in my application. It's a social network.
And I need to change one of images of the application automatically if user didn't touch the screen for 10 minutes for instance.
My first idea is to detect touches on each screen and depending on that implement "auto away".
But may be easier way exists. May be I can detect touches of the entire device in my application.
Thank you in advance!
You need to be increasing some variable that will tell you when your session "will" expire (in session or database) everytime you enter a new page.
For example, you store:
current time + 10 minutes
Then you create a function that you will be using in each page, that checks if the current time is lower than the variable you stored, then the user has been away for more that then minutes.
U need to keep a timer.
start in didFinishLaunching.
whenever user does anyinteraction reset the timer to 10mins.
if user interaction is not there for 10mins timer will expire.
Try this
Consider an app that was in the multitask bar, and was closed, clicking on the minus sign.
What is supposed to be the behavior of this app at restart?
Does the app restart from scratch with the splash screen and without old data?
Or does the app load saved data and restart without splash screen and with previous data reloaded?
Thank you.
The application should restore its previous state in as many cases as possible. Prior to multitasking, all the applications tried to do this, to give the users the impression of multitasking. With multitasking in iOS 4, this doesn't change. You still need to do this to:
Support older devices.
Keep the user experience the same even if the user opens tons of apps and the device frees memory automatically.
If its closed then it will start from "scratch" unless you use the app delegate methods which are fired to store data and create the functionality to reload somewhere specific in your app yourself.
The splash screen will show if there is loading time needed, just like when you start an app the first time.
I think a user who clicks the minus is probably doing it, either just to clean up, or because he/she would like the app to return to it's beginning setup, just as if the device was reset.
I handle the minus, just like that, and start fresh with the splash screen. (not sure what the apple guide recommends)
This operation (tapping on minus icon) is intended for freeing memory.
When Apple has introduced multitasking in iOS, usage of memory has increased a lot!
So, why you have to tap on minus to kill application? When do you have to do this?
When your device responsiveness is too bad.
After killing (closing) application, when you restart the app, it start from scratch or resume last operation depending on how the application has developed!
For example, look at FacebookApp. If you are logged-in and quit app, at next restart it's reopen your account and last page seen!
For something like a game, I would suggest you restore the user's state ONLY IF they were in the middle of a game, else just start from scratch. However, for anything else, always start from scratch.
If you do nothing, your app will probably start from scratch at the moment.
Hey guys. I have a navigation-based app, and I want to control what the app does when it enters the background. In this app, the user has usually made it to the 3rd or 4th view controller before hitting the home button.
As of now, pushing the home button forces the user to restart the app from the beginning every time. This is a pain because it takes near a minute for the user to get back to where he was.
Is there a way to "close" the app while keeping track of the user's last page? I know that applicationDidEnterBackground: only allows a few seconds to close-out the session, and I dont know of any other way to accomplish this.
If anyone has any ideas, please let me know. Thanks!
If your app is running on a 4.0+ device then the default behaviour will be to return to where the app was before it entered the background. If it is on an older iOS then you will have save any session information yourself.
First some background; for the tl;dr version skip to "the problem" below.
Background
This is really more of a user interface question than a technical one, but I think it fits better here than on the UI site anyway.
Since iOS (iPhone OS) 4.0 apps can run in the background, and actually always does so instead of quitting. Quitting an application requires pressing the home button, pressing it again, holding your finger on the application icon until it starts shaking, touching the "close" indicator, pressing the home button again. Not really intuitive.
The reason for this is of course that usually the user shouldn't care if the app is quit or just suspended, because it doesn't matter. But for some apps it does.
The problem
I have an app that logs location changes; think "RunKeeper" if that's familiar. The user starts the app, chooses to start recording (to a file), or just uses it to view distance, speed, etc. When the user is done (or wants to do something else), they hit the home button. The app disappears. Now one of several things happen:
The app quits, closing any ongoing recording (iPhoneOS 3.1.3 and below).
The app continues running in the background, using the GPS and draining the battery (iOS 4). This is appropriate if the user for example wanted to switch to the iPod app to change their soundtrack.
The app continues running in the background, using the GPS and draining the battery (iOS 4). This is completely inappropriate if the user was done and wanted to quit the app.
There is of course no way for the app to see the difference between cases three and four. A quick look around RunKeeper forums indicates that many users have no clue what is happening and get seriously confused by this.
Ideas
So what's the best way to solve this from a user interface point of view?
When the home button is pressed, go into background as is the default action. It's the user's problem to actually kill the app if they are done. It's the platforms fault that this is non-obvious and slightly tedious.
When the home button is pressed and a recording is in progress, continue in background. If we are not recording, quit the application.
Present a toggle widget somewhere in the application that allows the user to choose what happens when the home button is pressed. (This might run afoul of the HIG; I'm not sure)
...?
What do you think?
I though to the third option without reading at it ^^ (I don't think it would be against HIG)
So a "big" button when recording to change the "mode" ? Or a switch ;-) (Like "Continue Recording when in "background" ?")
And maybe asking the user about it when he start registering ? (with a default value available in prefs page ?)
And as you can change songs without quitting the app, maybe setting the default value as stopping record when the app is going to background.
But I haven't any other solution for you :-/
I want to use my iPhone to very easily create a timestamp whenever a certain event occurs (e.g. every time I cough). The goal is to build up a log file that can be analyzed later for trends.
My iPhone is passcode locked because of my Exchange policy, so the steps to do this if I were to create a conventional app are as follows:
Press home buttom
Slide to unlock
Enter passcode
(If applicable) Close whatever app is already open
Navigate to my app in the home screen & launch it. When the app is launched, it records a timestamp.
This turns a very simple write-only action into a somewhat annoying task I will probably abandon, given that it may occur dozens of times a day. Is there a way around these steps?
Here's a hack I've come up with:
Press the home button
Press the home button and sleep/wake button simultaneously, taking a screenshot
Each time I do this, an image is created in my photo library. After a couple of weeks, I transfer the (hundreds of) pictures to my PC, and run a script to extract the timestamps from the screenshots' metadata and build the log.
Any other ways of doing this, possibly using Voice Commands, hardware buttons, log files, or something else I might not be aware of?
Edit: iPhone 3GS, iOS 4.
iOS4.0? Here's one idea requiring a media player app running in the background. Make an app like Pandora, or a simpler audio player app that continually plays silence (keeps filling audio queue buffers with zeros, etc.), and that will continue to play this "music" in the background. Have it register for volume change notifications. Record a timestamp when you press one of the volume buttons (have to be careful to alternate so you don't hit the max or zero volume).