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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:34:15+00:00 2026-05-25T11:34:15+00:00

hi im working on an android messenger and i need to show the progress

  • 0

hi im working on an android messenger and i need to show the progress bar when sending and receiving files. could anyone help? for instance this is how i send the file,

@Override
    public boolean sendFile(String path,String ip, int port) {
    // TODO Auto-generated method stub


    try {


        String[] str = ip.split("\\.");

        byte[] IP = new byte[str.length];

        for (int i = 0; i < str.length; i++) {

            IP[i] = (byte) Integer.parseInt(str[i]);


        }
        Socket socket = getSocket(InetAddress.getByAddress(IP), port);
        if (socket == null) {
            Log.i("SO sendFILE","null");

            return false;
        }

        Log.i("SocketOP", "sendFILE-1");
        File  f = new File(path);


        BufferedOutputStream out = new BufferedOutputStream( socket.getOutputStream() );

        FileInputStream fileIn = new FileInputStream(f);
        Log.i("SocketOP", "sendFILE-2");
        byte [] buffer  = new byte [(int)f.length()];
        System.out.println("SO sendFile f.length();" + f.length());
        int bytesRead =0;
        while ((bytesRead = fileIn.read(buffer)) > 0) {
            out.write(buffer, 0, buffer.length);
            System.out.println("SO sendFile" + bytesRead);
        }
        out.flush();
        out.close();
        fileIn.close();
        Log.i("SocketOP", "sendFILE-3");






    } catch (IOException e) {
        return false;           
        //e.printStackTrace();
    }
    //  Toast.makeText(this, "Lvbvhhging...", Toast.LENGTH_SHORT).show();

    return true;        
}
    }

now where do i put the bar and how do i do that inorder to show the user the progress?

  • 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-25T11:34:16+00:00Added an answer on May 25, 2026 at 11:34 am

    try this ::

     private class xyz extends AsyncTask<Void, Void, Void> {
            private final ProgressDialog dialog = new ProgressDialog(tranning.this);
    
            @Override
            protected void onPreExecute() {
                this.dialog.setMessage("Please Wait...");
                this.dialog.show();
                // put your code which preload with processDialog  
            }
    
    
            @Override
            protected Void doInBackground(Void... arg0) {
                // put your code here
    Log.i("SocketOP", "sendFILE-1");
            File  f = new File(path);
    
    
            BufferedOutputStream out = new BufferedOutputStream( socket.getOutputStream() );
    
            FileInputStream fileIn = new FileInputStream(f);
            Log.i("SocketOP", "sendFILE-2");
            byte [] buffer  = new byte [(int)f.length()];
            System.out.println("SO sendFile f.length();" + f.length());
            int bytesRead =0;
            while ((bytesRead = fileIn.read(buffer)) > 0) {
                out.write(buffer, 0, buffer.length);
                System.out.println("SO sendFile" + bytesRead);
            }
            out.flush();
            out.close();
            fileIn.close();
                return null;
            }
    
            @Override
            protected void onPostExecute(final Void unused) {
                if (this.dialog.isShowing()) {
                  this.dialog.dismiss();
    
                }   
            }
        }
    

    and use this in main ::

        new xyz().execute();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on Android database type application. We need to show some reports.
I'm working with Android and Spinners and I need some help. I have a
I'm working with Android and I really need a fast way to get a
I am working on an Android service. I need to call RecognizerIntent from a
I'm working on Android, but this is a java question. I have an image
I am currently working on Android I have a xml which is like this:
I am working in android. I want to show simple google map in my
I am working on android development, I need a good UI designer which is
I am working on Android 3.0 and I need to know in my application
guys i am working on android 2.2 i am stuck where the user need

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.