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

  • SEARCH
  • Home
  • 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 8649037
In Process

The Archive Base Latest Questions

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

I have a single activity app that uses a PagerAdapter. In the OnCreate event

  • 0

I have a single activity app that uses a PagerAdapter. In the OnCreate event I trigger the inflation of all 7 of the pages in the PagerAdapter. The various pages have standard widgets, one page has a google Map. It all works well when testing in the AVD.

But what if my app is paused or stopped and then restarted or resumed? Does the inflation of all my pages in the pageradapter get deleted? Do I have to reinflate all the pages again?

More generally…

I’ve read a lot of articles about what happens with my app gets stopped or paused and what I should do upon restart or resume but I haven’t seen a precise accounting of what needs to be rebuilt and what does not need to be rebuilt. I read that “this is a great place to refresh the UI” but I’m not sure exactly what that means.

Begging questions might be…

is my internal state restored i.e. values of my variables, sqlLite db, file contents.

are the values in my widgets restored i.e. characters in a textbox.

How can I prevent corruption if the pause or stop can happen in the middle of a for loop or a code block?

Thanks,
Gary

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

    But what if my app is paused or stopped and then restarted or resumed?
    Does the inflation of all my pages in the pageradapter get deleted? Do
    I have to reinflate all the pages again?

    If by app you mean Activity, when it is paused this just means it is not the focused Activity right now. All the state is still there. This basically means that you cannot accept any foreground events until onResume(). If the OS decides to call, onSaveInstanceState(), you can can actually store things like values of instance variables or just flags for a new instance to read. You can’t store complex things here though. So things like Thread or Cursor instances will not be appropriate. Basically anything that is not “data.”

    In the case where the activity is destroyed or even the process killed, then yes you will need to rebind and reinflate everything. However the beauty of this, in most cases you don’t have to do anything special. Only in the cases that you may have written to a bundle in onSaveInstanceState() will you have to do some extra work.

    is my internal state restored i.e. values of my variables, sqlLite db, file contents.

    If the transition was only between onPause and onResume then yes. Everything should be fine. If there was a destroy or process kill, the activity will restart with onCreate() and have to reset all the state based on the Bundle savedInstanceState. I will address sqlite and files later down.

    are the values in my widgets restored i.e. characters in a textbox.

    Usually if they have saveEnabled(true) (most do) and for TextView there is a freezesText property that will make them remember the last text set on them. However, most of the time if you save your state correctly during the onSaveInstanceState() call, it’s probable that you are storing the state not just for UI but other means as well. In which case you might as well sync them when you go through the next onCreate()

    How can I prevent corruption if the pause or stop can happen in the
    middle of a for loop or a code block?

    So onPause() and onStop() occur on the main UI thread. If you are currently running code on the UI thread, it must complete before these other callbacks can occur. If you are running on some other thread, then yes you have to try to make outputs of task complete on the UI thread. It simplifies a lot of this.

    Kills on the other hand, can happen. This usually affects things outside your program’s memory though when we talk about corruption. Like if you had a file handle open or a sqlite cursor open, or a network socket open. With that, you sort of have to check the state before you use it.

    i.e

    • Make sure directories really exist before you read or write to them
    • Make sure the contents of files were properly written to previously (simple expected check-sums usually work here or version metadata).
    • Use transactions when using sqlite to make sure you only write data to your table(s) in complete atomic chunks so that you don’t have tables with rows referencing state in other tables that is not there.
    • Network connections will be reset, and things like your network protocol of choice should take care of sanity checking for you, along with the application being connected with.

    hopefully this helps, while it’s not fully complete, it’s a good starting approach.

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

Sidebar

Related Questions

I have an single Activity application that starts a Service and binds to it.
I have a single-threaded application that uses 3 SQLite databases in 3 different files
I have a web app that contains an activity log for actions the users
I have an app that goes between many different activities. One activity, my main
I have an Android app that consists of an activity and a service. Currently
Im trying to write a single activity app, extending ListActivity. I have a class
In my app, I want to have a single background image that I use
I have an app using fragments, all of which are contained in a single
I wish to have a single class which all of my Activity classes extend.
We have an iOS app that publishes certain activity to Facebook that contains links

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.