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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:21:18+00:00 2026-06-07T01:21:18+00:00

i have a function in an activity where i check something. I call a

  • 0

i have a function in an activity where i check something. I call a webservice in that function (in doInbackground method ) and depending on the result i start another activity.

That function is called in the onCreate method of the activity and the problem is that the execution of next instruction continue without waiting the result of my function.

Here is the code :

public class EditAccountActivity extends Activity {

 public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.edit_account);

    save.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

                checkConflict();

                Log.i("VERIF",
                        "WE GO HERE WITHOUT WAITING THE RESULT");
//i don't want to go here if we start the other activity in checkConflict
...


}}}

public void checkConflict() {

    final Intent intent = new Intent(this, ConflictFieldActivity.class);

    new WSDataAccount() {
        @Override
        public void onPostExecute(final ArrayList<ArrayList<String>> result) {



            if (modifiedTimeOnServer > modifiedTimeLocal
                    && !conflictWithFields(fieldLocalFirstStateMap,
                            fieldServerMap.getAccountFieldMap(),
                            modifiedTimeLocal, modifiedTimeOnServer)
                            .isEmpty()) {



                Toast.makeText(getApplicationContext(),
                        " EDITION CONFLICT !!!! ", Toast.LENGTH_LONG)
                        .show();
                startActivity(intent);
            }
        }
    }.execute(sessionName, accountId, "retrieveModifiedTime");

}}

Do you know another way to work with the result returned by “onPostExecute”, in order to wait my treatment before executing next instruction

  • 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-07T01:21:21+00:00Added an answer on June 7, 2026 at 1:21 am

    I guess the most simple for you is to call different methods of your Activity, depending on result;

    public class EditAccountActivity extends Activity {
       void foo(){}
       void boo(){}
    }
    

    And then

        @Override
        public void onPostExecute(final ArrayList<ArrayList<String>> result) {
            if(result){
                foo();
            }else{
                boo();
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an activity in whose onCreate method an Init function is called (the
I have function getCartItems in cart.js and I want to call that function in
I have function Start() that is fired on ready. When I click on .ExampleClick
i have this function which call a function to check CMS for info. but
I have following function in one Activity public void AppExit() { Editor edit =
I need to have a class with one activity that is performed once per
I have a function that looks like this: def post_count(self): return self.thread_set.aggregate(num_posts=Count('post'))['num_posts'] I only
I have a function to display a notification, which I call from various activities.
I have an DefaultHttpClient that don't check for certificates that I use at both
I have a function that updates a <div /> via AJAX: function update() {

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.