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 8648135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:14:39+00:00 2026-06-12T13:14:39+00:00

I am designing an Android App. My aim is that if the App is

  • 0

I am designing an Android App.

My aim is that if the App is killed while it was in the background, and if the user starts the app again then it should have the option to resume the App.

Now, my onStart function is called in two scenarios:

  1. When the activity is started for the first time
  2. Even if the activity started after the kill.

I want to check which can determine in the onStart(), that the app started from scratch, or it is resuming from previous state?

  • 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-12T13:14:40+00:00Added an answer on June 12, 2026 at 1:14 pm

    You can use shared preferences for tasks like these.

    In your onStop() function, set a flag in shared preferences like:

    SharedPreferences.Editor editor = getPreferences(MODE_PRIVATE).edit();
    editor.putString("killed", "yes");
    

    In your onStart(), retrieve the preference and check it like this:

    SharedPreferences prefs = getPreferences(MODE_PRIVATE); 
    String flag = prefs.getString("killed", null);
    
    if(flag!=null && flag.equals("yes")
    {
    //activity is resumed
    }
    else
    {
    //activity is started from scratch
    }
    

    for more info on shared preferences, see official docs here:
    http://developer.android.com/guide/topics/data/data-storage.html#pref

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

Sidebar

Related Questions

i am designing an app for android tablets. I have created a layout file
I've just finished designing a small android app and have now come to a
We're designing an Android app that has several activities which are working in a
I am designing an android app that needs to play a sound every minute
I am designing an app in xml android. I have been using lots of
I'm building the android application but I'm fed up while I'm designing my app
I am designing a simple app from tutorials that I have seen, and I
I'm designing a music player app for Android that will feature pop-up controls. I'm
I am designing an app that will have some activities separated in tabs. Some
I'm designing an API for an Android app. An iPhone requires a user 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.