Project Background:

First off I have very basic knowledge about Android development, and I'm currently performing practice assignments that have been designed to essentially give me a crash course in Android development. Per the assignment specs we've been asked to make "full use of the benefits of StackOverflow" in coming up with solutions to our tasks. In my application's current state, there is a LoginActivity and a MainActivity, the main activity contains 5 fragments that can be accessed via the MenuItem bar across the top of the MainActivity. Upon pressing any tab, current fragments are removed (if there are any - and per this logic there is never more than one non-headless fragment open at a time) and the new fragment is added to the MainActivity container view. Everything is pretty typical as far as I know and fragments are created using the newInstance() format. The fragment that I need to deal with in this iteration of my tasks is my MessageFragment which will contain a refresh button and TextView that will publish the results of the refresh.

My Task:

Per this assignment I am tasked with creating a retained fragment that will run a thread with Handler . The purpose of this practice scenario is to simulate content refreshes that occur when connecting to the web. For the practice scenario I am to create a runnable task that will be enqueued onto a thread that will return its result all the way to the MessageFragment . The result should be a random number displayed in the TextView . I am to pause the thread for 5 seconds before producing the result. I've been told to "keep in mind that in order to see the result after screen rotations you need to refresh the message fragment by quickly choosing some other tab and then returning to the message tab".

Key details:

Must use Handler / Looper / Thread approach to perform the simulation of networked content refresh

/ / approach to perform the simulation of networked content refresh Must have seamless orientation change handling

(IMPORTANT) Once implementing basic functions, we are to "fix" the refresh button (making it so that it isn't necessary to change tabs after orientation changes)

My questions: