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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:11:32+00:00 2026-06-03T11:11:32+00:00

i have written the code like below public class SplashScreen extends BaseActivity{ public void

  • 0

i have written the code like below

public class SplashScreen extends BaseActivity{

public void onCreate(Bundle savedInstanceState){        
  super.onCreate(savedInstanceState);
  new DownloadPlistTask().execute("background","Progress","yes");
}
private class DownloadPlistTask extends AsyncTask<String,String,String>{


 protected String doInBackground(String... dummy){
     return compareLocRemPlist();
 }
    protected void onProgressUpdate(String... progress){
      //some code here.
    }

  protected void onPostExecute(String result){
   //handle return type from doInBackground.
  }

 public String compareData(){
     final Timer timer = new Timer();
     timer.schedule( new TimerTask(){
       public void run(){
        //code regarding webservices.
        if(boolValue){
         //if the boolValue from the webservice is true,cancel the timer.
          timer.cancel();
          }
     },5*60*1000,5*60*1000);
     return "finish";
  }
 }  
}

In the above code from the onCreate() iam calling AsyncTask doInBackground in the doInBackground iam calling a method named compareData().In the compareData() method iam using a timer.The timer sends request for the webservice,in the webservice iam getting a boolean value,if it is true i need to return finish.If it is false i dont want to return finish,i should stay in the compareData() method,and for every five minutes it should send the request till i get true.But when the timer is waiting for the five minutes,during this time the statements after the timer is getting exetuted and the return value finish is returning to the doInBackground and the control is going to the onPostExecute() but in the background the timer is running.how can return finish when i cancel the timer

  • 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-03T11:11:33+00:00Added an answer on June 3, 2026 at 11:11 am

    Since you are running it in doInBackground, you can perform the check synchronously. So instead of a timer, you can make use of the Thread.sleep method.

    static final long RETRY_DURATION = 5*60*1000;
    public String compareData(){
        boolean boolValue = false;
        do{
            //code regarding webservices.
            if(!boolValue){
                try{
                    Thread.sleep(RETRY_DURATION);
                }catch(InterruptedException ex){
                    ex.printStackTrace();
                }
            }
        }while(!boolValue);
        return "finish";
    }  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a custom server control which (pseudo-code) looks like public class MyCustomCtrl
Hi I have written code like this @Id @Column(nullable=false) @GeneratedValue(strategy=GenerationType.AUTO) public int getUserID() {
In our application, I have seen code written like this: User.java (User entity) public
i want show tooltip with image tag and i have written code like below
I have always written my boolean expressions like this: if (!isValid) { // code
To remove white space from text i have written the below code.my requirement was
Ok below is the full code I have written for what is suppose to
I have a matrix class like below: template <size_t M, size_t N, typename T>
I have written code that opens 16 figures at once. Currently, they all open
I have written code in Java to access web cam,and to save image... I

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.