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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:06:27+00:00 2026-05-25T17:06:27+00:00

I tried to implement threads, asynctask from examples on the web but none of

  • 0

I tried to implement threads, asynctask from examples on the web but none of them run the way I want.

I have a class to send data to a web server.
It contains 3 tasks:
-grab an id
-get data from sql and build a json file
-send the json file

I’d like to implement a progress dialog or progressbar to show progress to the user waiting.

The progressdialog I last tested to show data grabbing from sqlite was based on Progress Bar Example.
Trouble is that when I try to generate my file more than 2 times, the thread is not starting…

So whats’s the best to be done in my case ?
I have a spinner to select what to send and a button to send.

When button is clicked, basically I have:

HttpResponse response = GetChantier(commentaire);
    //Checking response 
    if( response != null)
    {
        String _response=EntityUtils.toString(response.getEntity());
        int chantier_serveur = Integer.parseInt(_response.replaceAll("[\n\r]", ""))
        String fichier = DonneesToJson(db,chantier, chantier_serveur);
        HttpResponse response = SendJson ( chantier, fichier);
    }

I’d need to implement a progress for DonneesToJson and SendJson.

DonnesToJson grabs a cursor then build a json file while iterating the cursor.
SendJson is an HttpPost that sends a file and 2 fields.

I’m really new to java programming and threads.
Any help appreciated.

Regards.

  • 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-25T17:06:28+00:00Added an answer on May 25, 2026 at 5:06 pm

    Use Async task for doing Background task as follows.

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);  
        new Asyn_Task().execute("name","title");
    }
    
    
    class Asyn_Task extends AsyncTask<Void, Void, Void> {
        private final ProgressDialog dialog = new ProgressDialog(Facebook_Post_View.this);
        // can use UI thread here
        protected void onPreExecute() {
            this.dialog.setMessage("Loading...");
            this.dialog.setCancelable(false);
            this.dialog.show();
        }
        @Override
        protected Void doInBackground(String... param) {
            // TODO Auto-generated method stub
                        name=params[0]; //Like
                        title=params[1];
    
             // Do your all Stuffs
           return null;
        }
    
        @Override
        protected void onPostExecute(Void result) {
    
            if (this.dialog.isShowing()) {
                this.dialog.dismiss();
            }
        }
    }
    

    In these at position 0 name will available and at position 1 title will available.Similarly you can pass values as you like..

    For further reference check this Async Task

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

Sidebar

Related Questions

I tried to implement __concat__ , but it didn't work >>> class lHolder(): ...
I've searched the forum, and tried to implement the code in the threads I
Anyone who has tried to implement RoutedCommands in WPF using M-V-VM has undoubtedly run
I have been looking around for solutions, and tried to implement what is often
I tried to implement rtmps with red5 but was having an error that the
I want to implement a mutex in Java using atomic variables. I tried implementing
Hey, So I am new to Android and tried to implement a class that
I have been developing an iPad application in which I want to implement multithreading,
I tried to implement XOR swap in python. x,y= 10,20 x,y,x = x^y,x^y,x^y print('%s
I once tried to implement Comet in PHP. Soon, I found that PHP is

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.