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

  • Home
  • SEARCH
  • 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 6821991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:36:37+00:00 2026-05-26T21:36:37+00:00

I have a problem I created my progress dialog dialog = new ProgressDialog(InstallerActivity.this); I

  • 0

I have a problem

I created my progress dialog

 dialog = new ProgressDialog(InstallerActivity.this);

I have 12 apk files in my assets folder. I am trying to copy all 12 assets to sdcard with this function

 private void CopyAssets() {
        AssetManager assetManager = getAssets();
        String[] files = null;
        String[] files2 = null;
        try {
            files2 = assetManager.list("");
            List<String> sb = new ArrayList();
            for (String curfile : files2) {

                 if (curfile.endsWith("apk")) {

                 sb.add(curfile);
                 }
            }
            files = sb.toArray(new String[sb.size()]);

        } catch (IOException e) {
            Log.e("tag", e.getMessage());
        }

       dialog.setMax(files.length);
       dialog.setProgress(0);
        for(String filename : files) {
            InputStream in = null;
            OutputStream out = null;
            try {
              in = assetManager.open(filename);

              out = new FileOutputStream(externalPath + "/" + appsdir + "/" + filename);
              copyFile(in, out);
              in.close();
              in = null;
              out.flush();
              out.close();
              dialog.incrementProgressBy(1);

              out = null;
            } catch(Exception e) {
                Log.e("tag", e.getMessage());
            }       
        }
    }
    private void copyFile(InputStream in, OutputStream out) throws IOException {
        byte[] buffer = new byte[1024];
        int read;
        while((read = in.read(buffer)) != -1){
          out.write(buffer, 0, read);
        }
    }

But my app always crashes on 10 files, with an error: Window leaked. If I delete Log.e, it wont crash, but still copy only 10 files, not 12!

After googling I found that I need to use dialog.dismiss(), but I dont want to dissmiss it now, it is needed to show progress of 2 more elements!

Logcat:

11-19 18:22:13.473: D/dalvikvm(19931): GC_EXTERNAL_ALLOC freed 872 objects / 58552 bytes in 88ms
11-19 18:22:57.903: D/asset(19931): Data exceeds UNCOMPRESS_DATA_MAX (4412833 vs 3145728)
11-19 18:22:57.913: W/dalvikvm(19931): threadid=9: thread exiting with uncaught exception (group=0x4001d930)
11-19 18:22:57.943: E/AndroidRuntime(19931): FATAL EXCEPTION: Thread-10
11-19 18:22:57.943: E/AndroidRuntime(19931): java.lang.NullPointerException: println needs a message
11-19 18:22:57.943: E/AndroidRuntime(19931):    at android.util.Log.println_native(Native Method)
11-19 18:22:57.943: E/AndroidRuntime(19931):    at android.util.Log.e(Log.java:215)
11-19 18:22:57.943: E/AndroidRuntime(19931):    at com.installer.InstallerActivity.CopyAssets(InstallerActivity.java:284)
11-19 18:22:57.943: E/AndroidRuntime(19931):    at com.installer.InstallerActivity.access$1(InstallerActivity.java:246)
11-19 18:22:57.943: E/AndroidRuntime(19931):    at com.installer.InstallerActivity$3$2.run(InstallerActivity.java:169)
11-19 18:22:57.943: E/AndroidRuntime(19931):    at java.lang.Thread.run(Thread.java:1096)
11-19 18:22:58.883: E/WindowManager(19931): Activity com.installer.InstallerActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@460905c0 that was originally added here
11-19 18:22:58.883: E/WindowManager(19931): android.view.WindowLeaked: Activity com.installer.InstallerActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@460905c0 that was originally added here
11-19 18:22:58.883: E/WindowManager(19931):     at android.view.ViewRoot.<init>(ViewRoot.java:247)
11-19 18:22:58.883: E/WindowManager(19931):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
11-19 18:22:58.883: E/WindowManager(19931):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
11-19 18:22:58.883: E/WindowManager(19931):     at android.view.Window$LocalWindowManager.addView(Window.java:424)
11-19 18:22:58.883: E/WindowManager(19931):     at android.app.Dialog.show(Dialog.java:241)
11-19 18:22:58.883: E/WindowManager(19931):     at com.installer.InstallerActivity$3.onClick(InstallerActivity.java:123)
11-19 18:22:58.883: E/WindowManager(19931):     at android.view.View.performClick(View.java:2449)
11-19 18:22:58.883: E/WindowManager(19931):     at android.view.View$PerformClick.run(View.java:9027)
11-19 18:22:58.883: E/WindowManager(19931):     at android.os.Handler.handleCallback(Handler.java:587)
11-19 18:22:58.883: E/WindowManager(19931):     at android.os.Handler.dispatchMessage(Handler.java:92)
11-19 18:22:58.883: E/WindowManager(19931):     at android.os.Looper.loop(Looper.java:123)
11-19 18:22:58.883: E/WindowManager(19931):     at android.app.ActivityThread.main(ActivityThread.java:4627)
11-19 18:22:58.883: E/WindowManager(19931):     at java.lang.reflect.Method.invokeNative(Native Method)
11-19 18:22:58.883: E/WindowManager(19931):     at java.lang.reflect.Method.invoke(Method.java:521)
11-19 18:22:58.883: E/WindowManager(19931):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-19 18:22:58.883: E/WindowManager(19931):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-19 18:22:58.883: E/WindowManager(19931):     at dalvik.system.NativeStart.main(Native Method)

Edit:
Seems like this is not a progressdialog issue. Fixed log.e line and got new error:

11-19 19:17:39.533: E/tag(20559): Something went wrong while copying files
11-19 19:17:39.533: E/tag(20559): java.io.IOException
11-19 19:17:39.533: E/tag(20559):   at android.content.res.AssetManager.readAsset(Native Method)
11-19 19:17:39.533: E/tag(20559):   at android.content.res.AssetManager.access$700(AssetManager.java:36)
11-19 19:17:39.533: E/tag(20559):   at android.content.res.AssetManager$AssetInputStream.read(AssetManager.java:571)
11-19 19:17:39.533: E/tag(20559):   at com.installer.InstallerActivity.copyFile(InstallerActivity.java:292)
11-19 19:17:39.533: E/tag(20559):   at com.installer.InstallerActivity.CopyAssets(InstallerActivity.java:276)
11-19 19:17:39.533: E/tag(20559):   at com.installer.InstallerActivity.access$1(InstallerActivity.java:247)
11-19 19:17:39.533: E/tag(20559):   at com.installer.InstallerActivity$3$2.run(InstallerActivity.java:170)
11-19 19:17:39.533: E/tag(20559):   at java.lang.Thread.run(Thread.java:1096)

Why it cant copy after 10th element from assets?

Thanks

  • 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-26T21:36:37+00:00Added an answer on May 26, 2026 at 9:36 pm

    Excuse me for that misunderstanding.

    The problem was with assets. I folowed this blog post http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-apps/ and renamed files to .jpg. now it works.

    Seems that it is an android bug that does-not allow to handle assets-files bigger than 4mb.

    Thanks everyone for you help!

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

Sidebar

Related Questions

I'm new to android and have been stuck on this problem for a long
I have problem with dynamically created image (JavaScript). I want to change the innerHTML
I have problem with Oracle 9.2 and JMS. I created PL/SQL routine to send
I have a peculiar problem. I created a normal Objective C class called SampleTable.
I have created Excel Sheet using Java program. It works fine. My problem is,
Here is my problem. I have created a pretty heavy readonly class making many
I am having a problem using the Unity Application Block, I have created a
I'm having a problem with mixing managed and unmanaged code. I have created two
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I've created a copy utility in c# (.NET 2.0 Framework) that copies files, directories

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.