1. Download our Official Android App: Forums for Android!

Apps Ensure code runs after Activity is made visible?

Discussion in 'Android Development' started by safibaba, May 30, 2010.

  1. safibaba

    safibaba Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    15
    Joined:
    May 3, 2010

    May 3, 2010
    15
    0
    15
    Hi All

    I have an activity (hi score table) which makes a web call and displays the retrieved data. It's called using an intent from within an already running activity.

    The problem I have is to make the activity display first..and then trigger the web call, so that I can show a loading symbol. At the moment, you don't see anything until the web call is finished, and then it shows the screen.

    My book says that I should place my web call in onStart(), but the activity doesn't show until after the code I place there has completed.

    Can anyone tell me where to place my initialisation code, so that it doesn't hold up the activity being displayed?

    Hope that makes sense!
     

    Advertisement

  2. rogerlebo

    rogerlebo Lurker
    Rank:
    None
    Points:
    5
    Posts:
    4
    Joined:
    Sep 15, 2010

    Sep 15, 2010
    4
    0
    5
    Yes, it makes sense.
    I need the same thing.
    Did you find a solution about that?

    thanks!
     
  3. Lemoncog

    Lemoncog Newbie
    Rank:
    None
    Points:
    36
    Posts:
    26
    Joined:
    Feb 23, 2011

    I haven't tried it yet but could you not put all the code for retrieving the data into another function, and run that function on a new thread like so :-

    new Thread() {
    @Override public void run() {
    //YOUR FUNCTION
    }
    }.start();

    That should let your activity load without pause, then you can use a loading/progress bar to show that the function is still working on retrieving data.
     

Share This Page

Loading...