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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:22:57+00:00 2026-05-28T03:22:57+00:00

Some specific situation: I have two Activities . FirstActivity loads data from network(~100 kb)

  • 0

Some specific situation:

I have two Activities. FirstActivity loads data from network(~100 kb) and is able to launch SecondActivity through startActivityForResult(). After getting result another network call should be triggered. All that works fine, except the performance. Here is the problem.

I trigger AsyncTask from onActivityResult(), or onResume() or onPostResume(). I expect that SecondActivity finishes, FirstActivity gets shown and the ProgressBar displayed, indicating my downloading works. But instead I see the following:

SecondActivity freezes, the FirstActivity gets launched(i see it in logs), AsyncTask triggered and FirstActivity gets shown only when AsyncTask finished it’s work!

It is also strange, because I use exactly the same code when firstly start FirstActivity and all works as expected.

So, the question:

What is the difference between launching AsyncTask from onCreate() and onActivityResult()? Why android behaves like that? Is it version specific?

Thanks a lot.

Some code:

Activity A(first):

void onCreate() {
    super.onCreate();
    setupUI();
    code = 1;
    launchLoading(code);
}


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    launchLoading(resultCode);
}

Activity B(second):

listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            setResult(i);
            finish();
        }
 });

UPD:

I create a list of custom views(~ 50) in onPostExecute() method. Why it is causing troubles?

  • 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-05-28T03:22:58+00:00Added an answer on May 28, 2026 at 3:22 am

    Thanks to all. The problem has been found in other place. In FirstActivity I have a list of custom views. Each one holds a small bitmap, but the count of these views are close to 50. So, when you return to the FirstActivity, onMeasure() is called for each of that view. It is performance important to do this as fast as possible. When I improved this method the problem has gone.

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

Sidebar

Related Questions

Consider a situation. We have some specific C++ compiler, a specific set of compiler
Let's imagine I have two threads which execute some database-oriented code in thread-specific TransactionScopes
I have some specific id like 1,2,5,11,64589 in solr (int type) I want to
How can I have a WinForms program do some specific thing whenever a certain
I'm trying to filter some XML in JavaScript using E4X and have some specific
My application requires events to be fired based on some specific activities that happen.
As a project over summer while I have some downtime from Uni I am
I have two activities one displaying map view and another listview, the main objective
Situation I have two .NET solutions ( Foo and Bar ) and a common
I have a specific situation where I've got an object that I want 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.