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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:32:26+00:00 2026-06-11T05:32:26+00:00

I have two blocks of validation code that I need to execute in a

  • 0

I have two blocks of “validation” code that I need to execute in a specific order, but the code in the onPostCreate() event is firing before the code in the onCreate() event, and I suspect it may have something to do with the Preference Store.

Some pseudo-code may help explain:

onCreate()
{
  prefs = PreferenceManager.getDefaultSharedPreferences(this);
  email = prefs.getString("email", "noemail@noemail.com").toString();
  if (email.equals("noemail@noemail.com")) 
  {
    //user has not supplied email address, show alert dialog
    warning();
  }
}

The warning() method just builds an alert dialog box letting the user know that they need to enter an email address, and when they click “OK” it launches the Preferences activity so they can supply the email address.

onPostCreate()
{
  carrier = manager.getNetworkOperatorName();
  if(carrier.equals("SPRINT"))
  {
    //call web service to validate carrier compatibility
    //if web service returns "FALSE" call warning2();
  }
}

The warning2() method does the same thing as warning() – it builds an alert dialog to let the user know their carrier is not compatible.

Even though warning() is called in onCreate(), and warning2() is called in onPostCreate(), currently the app is throwing the warning2() dialog box before the warning() dialog box, and I don’t understand why.

Is it because the second validation calls a web service and the first validation is checking the Preference store, and somehow the web service call is completing before the Preference store can be accessed?

How can I enforce that the first validation and warning() are dealt with before the second validation and warning2()?

  • 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-11T05:32:27+00:00Added an answer on June 11, 2026 at 5:32 am

    Are you sure it’s calling the warning2 dialog first, or are you just seeing it first? Dialogs don’t block the main activity, so it’s probably calling warning first, but immediately after that, it calls warning2, which would cover the first dialog. So you would see warning2, and not see warning until it was dismissed, since it’s layered directly below it.

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

Sidebar

Related Questions

I have two code blocks that are PHP functions that do two different things.
I have the following two code blocks. Code block 1 var checkboxes = $(div.c1
I have two almost similar source code trees, but do not have access to
I have an issue with my code, I have two blocks of code of
I have two GCD blocks that are async. The first is for the background
In C# I have two blocks of code which open and write to processes
I have the following dilemma with two elements (menu items) that I need to
I have two blocks in HTML5 canvas. Blue Block ie fixed in the canvas
I have my main stage, and I have two objects (blocks), these two objects
I have these div blocks called columns where each column div contains separate two

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.