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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:52:42+00:00 2026-06-02T10:52:42+00:00

I’m trying to write a test app to zip and unzip a file. I

  • 0

I’m trying to write a test app to zip and unzip a file. I found a open source library for doing the file compression/uncompression but as you can guess that does take sometime so I can’t run it in the main ui so I thought I’d use AsyncTask to do the heavy lifting on a background thread, and then just throw up started, and a finished message and everything would be fine. but I’m having two big problems here. when I hit the button, it does go and unzip the files but it it appears to do it in the main ui not in a background thread as the app will lock up and I do get the anr screen, plus I’m watching for any new threads do appear using the ddms view and I don’t see any. if I tell it I want to wait it out it will unzip the files. but of course I do not want the program to appear to freeze or anr on me the other problem is I have it set to update the button text both right after it’s clicked on, and then again when the aysc task finishes but yet I don’t see either change happen, i did change the texts so that they where all different so I could tell. also it’s supposed to set a text field in the status message. I don’t think the onPostExecute is ever being called. can someone tell me what is going on here?

package net.pawworks.sandbox.svc;

import java.io.File;
import net.pawworks.utils.mainlib.filetools;
import net.pawworks.utils.mainlib.zipper;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class TestserviceActivity extends Activity {
    /** Called when the activity is first created. */
    String readpath= filetools.sdcardpath()+"/ziptestin/";
    TextView readstatus;
    Button readbut;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ziptest);
        File setup = new File(filetools.sdcardpath()+"/ziptestout");
        setup.mkdir();
        setup = new File(filetools.sdcardpath()+"/ziptestin/");
        setup.mkdir();
        readstatus = (TextView)findViewById(R.id.readstatus);
        readbut = (Button)findViewById(R.id.readit);
        readbut.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v)
            {
                readbut.setText("Loading.....");
                String status="";
                // TODO Auto-generated method stub
                File setup = new File(readpath+"jpgs.zip");
                if(setup.canRead())
                {
                    status="File Readable\n";
                    new unpackit().doInBackground(new String[]{"jpgs.zip",status} );
                    readbut.setText("Read!");
                }
                else {status = "File not Readable:"+setup.toString();readstatus.setText(status);readbut.setText("Read.");}


            }
        });
       }
    private class unpackit extends AsyncTask<String, Void, String>
    {

        @Override
        protected String doInBackground(String... params) 
        {
            // TODO Auto-generated method stub
            Log.e("asynctask", "1:"+params[0]+"2:"+params[1]);
            zipper d = new zipper(readpath+"jpgs.zip",filetools.sdcardpath()+"/ziptestout/");
            d.unzip();
            return params[1]+"\n"+d.status();
        }

        @Override
        protected void onPostExecute(String result)
        {
            readstatus.setText(result);
            readbut.setText("Read?");
        }
    }
}
  • 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-02T10:52:42+00:00Added an answer on June 2, 2026 at 10:52 am

    You want to be calling

    new unpackit().execute(args);
    

    rather than doInBackground(args). It’s analogous to calling start() on a thread, rather than run() – in this case, your UI thread is just executing the code in doInBackground(), but it’s not invoking anything else.

    For more information see the documentation and sample code here.

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

Sidebar

Related Questions

I am trying to render a haml file in a javascript response like so:
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.