Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9132615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:20:26+00:00 2026-06-17T08:20:26+00:00

I am building a cinema listing app, where the user can drill down thru

  • 0

I am building a cinema listing app, where the user can drill down thru the dataset to finally end up with a listing for a specific movie/theater/etc.

Now assume the user pauses using the app for 7 days. When reopening the app what he should not see are the listings from 7 days ago. But if the user just puts the app in background for a few minutes, the user should continue just where he left. I thought I could solve this issue by killing the app after a certain amount of time in background. This is the code:

static BOOL goingToQuit = NO;

#define KILL_IN_BACKGROUND_AFTER_SECS 300

- (void)applicationDidEnterBackground:(UIApplication *)application
{
  goingToQuit = YES;

  UIApplication* app = [UIApplication sharedApplication];
  UIBackgroundTaskIdentifier __block bgTask;
  bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
    [app endBackgroundTask:bgTask];
    bgTask = UIBackgroundTaskInvalid;
  }];

  if(UIBackgroundTaskInvalid != bgTask) {
    // Start the long-running task to kill app after some secs and return immediately.
    dispatch_after( dispatch_time(DISPATCH_TIME_NOW, KILL_IN_BACKGROUND_AFTER_SECS * 1e09), 
      dispatch_get_main_queue(), ^{
        if(goingToQuit) exit(0);
        [app endBackgroundTask: bgTask];
      });
  }
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
  // cancel ongoing background suicide.
  goingToQuit = NO;
}

What I see on my device is this: after KILL_IN_BACKGROUND_AFTER_SECS the app gets killed. After restarting the device logs show that the app got a new PID, entries showing the restart etc. Yet the device does not show the default.png startup image, but the screenshot of where the user has been before.

On the other hand if the user kills the application explicitely (double click on home button, tap & hold, click – on app) before he is restarting it the application starts with its default.png start up screen. This is the behaviour I want when killing the app programmatically.

Does anyone have an idea how to accomplish this? Any idea is highly appreciated.

BTW: As a workaround I tried to hide the main window during applicationDidEnterBackground and show it again on applicationWillEnterForeground. This, however, is highly confusing to the user when he is switching between apps.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:20:27+00:00Added an answer on June 17, 2026 at 8:20 am

    In your app delegate’s applicationDidEnterBackground you can display a view in front of the rest of your views, which the OS will grab as the last visible thing and which will be displayed when the app becomes active again (if it’s still alive).

    In your app delegate’s applicationDidBecomeActive you can check to see if the data needs updating; if not then simply dismiss the view (animation is nice), and if so then first update (or just clear out) your data and then dismiss the view.

    This is fairly common in apps. Many just use the default.png startup image, since users are accustomed to seeing it when the app launches normally.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Building a Shopping Cart app. Some products have options, some don't. I visitor can
Building a Django app on a VPS. I am not very experienced with setting
Building our Android app from Ant fails with this error: [apply] [apply] UNEXPECTED TOP-LEVEL
Building an NSCharacter set to restrict a UITextField for entering user names. I want
Building on another SO question , how can one check whether two well-formed XML
Building an iPad app. I have a button on my main view that I
Building an app that gets a list of widgets from an SQlite database then
Building an iOS app that needs to display some HTML string in a UIWebView
Building off Does Perl have an enumeration type? , how can I perform dynamic
Building my first web app using Yii and wondering if it is best to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.