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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:41:00+00:00 2026-05-23T18:41:00+00:00

I’m trying to get my user interface to react to events (like button presses,

  • 0

I’m trying to get my user interface to react to events (like button presses, thread completions, etc.) in real time in Android (obviously).

I have a button layout, and one of the buttons is used to copy an unknown number of files from a remote computer using FTP. The FTP part of all this is working very well, but I just cannot find a way to let the user know the state of things:

The states, as I see them are:
1) Selected “Download Files” from “normal” menu.
2) Pressed Confirm (the download process may be quite lengthy and perhaps I don’t want to select it by mistake — however now it’s a separate thread so may need to re-think that.
3) Downloading
4) Download complete, restore normal menu

One of the things I hoped would work would be to run the FTP code in a separate thread, and by using the thread.isAlive() construction, wait for the thread to complete and change the display accordingly.

The only thing I haven’t been able to do is display that files are downloading. Regardless of what I try, the display jumps from the “Confirm Download” view to the “Normal Menu” view. (Please note, these are not Views as Android defines them in any way.)

Code follows:

Btn.setOnClickListener (new View.OnClickListener()
{
    @Override
    public void onClick (View v)
    {
        hideTempWidgets();
        Btn01.setVisibility (View.GONE);                
        Btn02.setVisibility (View.GONE);                
        Btn03.setVisibility (View.GONE);                

        verfBtn.setVisibility (View.VISIBLE);
        verfBtn.setText ("Press to Verify");
        verfBtn.setOnClickListener (null);
        verfBtn.setOnClickListener (new View.OnClickListener()
        {
            @Override
            public void onClick (View v)
            {
                runOnUiThread (new Runnable()
                {
                    public void run()
                    {
                        verfBtn.setText ("Downloading...");
                    }
                });

                Thread temp = new Thread (new Runnable()
                {
                    public void run()
                    {
                        try
                        {
                            FileTransfer.getFiles (getAddr().trim());
                        }
                        catch (SQLException e)
                        { }
                    }
                }, "ftp");

                temp.start();
                while (temp.isAlive());                                 

                verfBtn.setVisibility (View.GONE);
                Btn01.setVisibility (View.VISIBLE);
                Btn02.setVisibility (View.VISIBLE);
                Btn03.setVisibility (View.VISIBLE);
                alert (true, VIBE_BLIP);
            }
        });
    }
});

Has anybody faced this and come up with a decent solution??

What’s not happening is the setText to “Downloading…”, or at least, if it does, not when I want it to and too fast to see… Finally, what’s especially frustrating is that that command does work properly when I remove the code to run the FTP thread.

Thanks,
R.

  • 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-23T18:41:01+00:00Added an answer on May 23, 2026 at 6:41 pm

    This task seems to be perfect for Async Task. Basically Async Task is a Thread with a built in, thread safe component to allow you to publish updates to the UI and notify when the task is complete.
    A popular idea is to show a spinner or progress bar, until the AsyncTask is complete, then dismiss it.

    For more information about Async Task see: http://developer.android.com/reference/android/os/AsyncTask.html

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.