0

I have an activity that loads content from the internet when it initially loads, however the order it takes is:

1) User hits button to go to new activity
2) App stays on old activity
3) App loads content from internet (usually takes about a second or two)
4) App brings user to new activity with content already loaded

Now this is fine, however it can be confusing for a user because while they are still on the original activity, there is no indication that their input did anything. If the user were to click the button again, it wouldn't register that as another click on the original activity, it would register that as a click on the new activity which is still loading, which may cause a user to end up somewhere they did not wish to be.

I'd like to be able to fix this by having the order of the process be:

1) User hits button to go to new activity
2) Old activity disappears, brings user to "blank" new activity without content loaded
3) Display a loading wheel
4) App loads content from internet
5) Content is displayed and loading wheel disappears.

However I can't figure out how to accomplish this, I placed all my code in the onResume() method because I thought that would work, but the content loaded the same way as it always has, does anyone have any suggestions on how to accomplish what I want? Here is the code in my onResume() method:

protected void onResume() {
    super.onResume();
    setContentView(R.layout.coupon);

    //method call to access the URL needed to display the content
    accessURL(Global.contentURL);

} 

Any help would be greatly appreciated.

shadowarcher
  • 3,265
  • 5
  • 21
  • 33

1 Answers1

0

You can use an AsyncTask that creates a ProgressDialog while it fetches the data in the background. There are many questions about this on SO (e.g. How to use AsyncTask to show a ProgressDialog while doing background work in Android?) as well as on the Internet.

Community
  • 1
  • 1